Skip to content

Commit

Permalink
Split xxd build to separate compile/link steps
Browse files Browse the repository at this point in the history
Previously xxd was built in a single compiler command, which works, but
on macOS this makes it impossible to get reproducible builds when
building with debug symbols (-g). This is because on macOS the linker
includes a debug map reference to the original .o file in the executable
and when a binary is compiled/linked in one command, the .o file
reference is pointing to a temp folder location that is not relative or
deterministic. Even if we strip the binary of debug symbols post-build,
this info would affect the generation of the UUID metadata of the
binary.

On Linux this doesn't matter because the executable has the entire DWARF
info and only refers back to the .c file, and does not need to point to
the .o file.

Program behavior-wise xxd should be identical to before.
  • Loading branch information
ychin committed Oct 23, 2024
1 parent aeb1c97 commit 4c0e67b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/xxd/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# The most simplistic Makefile

xxd: xxd.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -DUNIX -o xxd xxd.c $(LIBS)
xxd: xxd.o
$(CC) $(LDFLAGS) -DUNIX -o xxd xxd.o $(LIBS)

xxd.o: xxd.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) -DUNIX -o xxd.o xxd.c

clean:
rm -f xxd xxd.o

0 comments on commit 4c0e67b

Please sign in to comment.