Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homogenize paths for source files during compilation #188

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

duthils
Copy link

@duthils duthils commented Oct 7, 2022

Why:

  • Compiling a .o file alone will compile with -c file.c
  • Compiling a .lo file alone will create the corresponding .o files with -c ./file.c
  • Building with make -j1 will only execute the .lo rules; the .o rules will be skipped since the .o files are already created from the .lo rules with option -c ./file.c
  • Building with make -j2 will execute the .lo rules and the .o rules in parallel, creating the .o file with option -c file.c
  • assert() captures the path of the source file (taken from the -c option) in the compiled binary in order to display the source of the assertion error
  • Hence the compiled binaries are not reproducible depending on the number of make parallel jobs

Example:

  • when compiling examples/ldns-dane with make -j1, the binary contains the string ./examples/ldns-dane.c
  • when compiling examples/ldns-dane with make -j2, the binary contains the string examples/ldns-dane.c

@wtoorop
Copy link
Member

wtoorop commented Jul 12, 2024

Is this safe with different build dirs?

@duthils
Copy link
Author

duthils commented Jul 12, 2024

No, you're right, the following example scenario does not work:

mkdir build
cd build
../configure --with-examples --with-drill
make -j1

I'll look for a better fix.

Why:

* Compiling a .o file alone will compile with "-c file.c"
* Compiling a .lo file alone will create the corresponding .o files with "-c ./file.c"
* Building with "make -j1" will only execute the .lo rules; the .o rules will
  be skipped since the .o files are already created from the .lo rules with
  option "-c ./file.c"
* Building with "make -j2" will execute the .lo rules and the .o rules in
  parallel with option "-c file.c"
* assert() captures the path of the source file (taken from the -c option) in
  the compiled binary in order to display the source of the assertion error
* Hence the compiled binaries are not reproducible depending on the number of
  make parallel jobs

Example:

* when compiling examples/ldns-dane with "make -j1", the binary contains the
  string "./examples/ldns-dane.c"
* when compiling examples/ldns-dane with "make -j2", the binary contains the
  string "examples/ldns-dane.c"
@duthils
Copy link
Author

duthils commented Jul 12, 2024

I updated the branch with a different fix that works with different build directories than ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants