-
Notifications
You must be signed in to change notification settings - Fork 588
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
build: use full paths on compile/link targets #6158
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Make it more similar to the assert() message format for consistency. Example: Before: firejail: main.c:100: main: Assertion `1 == 2' failed. Error src/firecfg/main.c:100 main(): malloc: Cannot allocate memory After: firejail: main.c:100: main: Assertion `1 == 2' failed. Error src/firecfg/main.c:100: main: malloc: Cannot allocate memory This amends commit b963fe4 ("Improve errExit error messages", 2023-06-16) / PR netblue30#5871.
1abb441
to
0256a53
Compare
This makes the compile commands clearer when building in parallel (with `make -j`) and ensures that `__FILE__` includes the full build-time path (relative to the root of the repository) whenever it is referenced, such as in failed assert() messages (currently the full path is only shown in errExit() messages). Example: Before: firejail: main.c:100: main: Assertion `1 == 2' failed. Error src/firecfg/main.c:100: main: malloc: Cannot allocate memory After: firejail: ../../src/firejail/main.c:100: main: Assertion `1 == 2' failed. Error ../../src/firecfg/main.c:100: main: malloc: Cannot allocate memory Commands used to search and replace: $ git grep -Ilz '^MOD_DIR =' -- '*Makefile' | xargs -0 -I '{}' \ sh -c "printf '%s\n' \"\$(sed -E \ -e 's|^MOD_DIR = src/(.*)|MOD = \\1\\nMOD_DIR = \$(ROOT)/src/\$(MOD)|' \ -e 's:^(PROG|SO) = [^.]+(\.so)?$:\\1 = \$(MOD_DIR)/\$(MOD)\2:' \ '{}')\" >'{}'" $ git grep -Ilz '^HDRS :=' -- '*.mk' | xargs -0 -I '{}' \ sh -c "printf '%s\n' \"\$(sed -E \ -e 's|wildcard (\*\..)|wildcard \$(MOD_DIR)/\\1|' '{}')\" >'{}'" Note: config.mk.in, src/fnettrace/Makefile and src/include/common.h were edited manually. This is a follow-up to netblue30#5871.
0256a53
to
5b1bd33
Compare
kmk3
added a commit
that referenced
this pull request
Jan 20, 2024
kmk3
added a commit
to kmk3/firejail
that referenced
this pull request
Jan 22, 2024
Instead of manually specifying which source files depend on which headers, use compiler flags to automatically generate depfiles (.d), which declare the correct header (make) dependencies for each source file (.c). Use `-MMD` (which ignores system headers) to generate the dependencies and `-MP` to prevent make from complaining when a header file is removed while it is listed as a dependency in a depfile. If depfiles exist, just include them. If not, make each object file (.o) unconditionally depend on all header files in its source directory and in src/include, to ensure that rebuilds are done when needed. The latter case applies for the first build after `make clean` (which would build everything anyway) and when the compiler does not support generating depfiles. Note that both gcc and clang have supported these options for a long time. Misc: This depends on the changes from commit 5b1bd33 ("build: use full paths on compile/link targets", 2023-07-02) / PR netblue30#6158 to avoid issues with make dependency tracking.
kmk3
added a commit
to kmk3/firejail
that referenced
this pull request
Jan 22, 2024
Instead of manually specifying which source files depend on which headers, use compiler flags to automatically generate depfiles (.d), which declare the correct header (make) dependencies for each source file (.c). Use `-MMD` (which ignores system headers) to generate the dependencies and `-MP` to prevent make from complaining when a header file is removed while it is listed as a dependency in a depfile. If depfiles exist, just include them. If not, make each object file (.o) unconditionally depend on all header files in its source directory and in src/include, to ensure that rebuilds are done when needed. The latter case applies to the first build after `make clean` (which would build everything anyway) and when the compiler does not support generating depfiles. Note that both gcc and clang have supported these options for a long time. Misc: This depends on the changes from commit 5b1bd33 ("build: use full paths on compile/link targets", 2023-07-02) / PR netblue30#6158 to avoid issues with make dependency tracking.
kmk3
added a commit
to kmk3/firejail
that referenced
this pull request
Jan 23, 2025
This considerably speeds up the execution of the relevant steps, most noticeably on scan-build: * scan-build: 121s to 55s (-54.5%) * cppcheck: 51s to 30s (-41.2%) * cppcheck-old: 21s to 11s (-47.6%) Note: The above uses the average time of 3 runs on master (commit bd946e3 ("Merge pull request netblue30#6624 from powerjungle/chore/update-security-md", 2025-01-21)) [1] [2] [3] and 3 runs on this branch[4] [5] [6]. Note: This considers only the steps themselves, as the total time of each job varies a lot between runs, mostly due to the apt-get update/install steps. For example, the same `apt-get install` command took 3 seconds on [7] and 132 seconds on [8]. Related commits: * 500d8f2 ("ci: run make in parallel where applicable", 2023-08-14) / PR netblue30#5960 * 5b1bd33 ("build: use full paths on compile/link targets", 2023-07-02) / PR netblue30#6158 [1] https://github.com/netblue30/firejail/actions/runs/12928036246 [2] https://github.com/netblue30/firejail/actions/runs/12928180264 [3] https://github.com/netblue30/firejail/actions/runs/12928238010 [4] https://github.com/netblue30/firejail/actions/runs/12927984482/attempts/2 [5] https://github.com/netblue30/firejail/actions/runs/12927984482/attempts/3 [6] https://github.com/netblue30/firejail/actions/runs/12927984482/attempts/4 [7] https://github.com/netblue30/firejail/actions/runs/12928180264/job/36054893393 [8] https://github.com/netblue30/firejail/actions/runs/12881736117/job/35912783635
kmk3
added a commit
to kmk3/firejail
that referenced
this pull request
Jan 24, 2025
This considerably speeds up the execution of the relevant steps, most noticeably on scan-build: * scan-build: 121s to 55s (-54.5%) * cppcheck: 51s to 30s (-41.2%) * cppcheck-old: 21s to 11s (-47.6%) Note: The above uses the average time of 3 runs on master (commit bd946e3 ("Merge pull request netblue30#6624 from powerjungle/chore/update-security-md", 2025-01-21)) [1] [2] [3] and 3 runs on this commit[4] [5] [6]. Note: This considers only the steps themselves, as the total time of each job varies a lot between runs, mostly due to the apt-get update/install steps. For example, the same `apt-get install` command took 3 seconds on one scan-build job run[7] and 132 seconds on another scan-build job run[8]. Related commits: * 500d8f2 ("ci: run make in parallel where applicable", 2023-08-14) / PR netblue30#5960 * 5b1bd33 ("build: use full paths on compile/link targets", 2023-07-02) / PR netblue30#6158 [1] https://github.com/netblue30/firejail/actions/runs/12928036246 [2] https://github.com/netblue30/firejail/actions/runs/12928180264 [3] https://github.com/netblue30/firejail/actions/runs/12928238010 [4] https://github.com/netblue30/firejail/actions/runs/12927984482/attempts/2 [5] https://github.com/netblue30/firejail/actions/runs/12927984482/attempts/3 [6] https://github.com/netblue30/firejail/actions/runs/12927984482/attempts/4 [7] https://github.com/netblue30/firejail/actions/runs/12928180264/job/36054893393 [8] https://github.com/netblue30/firejail/actions/runs/12881736117/job/35912783635
kmk3
added a commit
that referenced
this pull request
Jan 25, 2025
This considerably speeds up the execution of the relevant steps, most noticeably on scan-build: * scan-build: 121s to 55s (-54.5%) * cppcheck: 51s to 30s (-41.2%) * cppcheck-old: 21s to 11s (-47.6%) Note: The above uses the average time of 3 runs on master (commit bd946e3 ("Merge pull request #6624 from powerjungle/chore/update-security-md", 2025-01-21)) [1] [2] [3] and 3 runs on this commit[4] [5] [6]. Note: This considers only the steps themselves, as the total time of each job varies a lot between runs, mostly due to the apt-get update/install steps. For example, the same `apt-get install` command took 3 seconds on one scan-build job run[7] and 132 seconds on another scan-build job run[8]. Related commits: * 500d8f2 ("ci: run make in parallel where applicable", 2023-08-14) / PR #5960 * 5b1bd33 ("build: use full paths on compile/link targets", 2023-07-02) / PR #6158 [1] https://github.com/netblue30/firejail/actions/runs/12928036246 [2] https://github.com/netblue30/firejail/actions/runs/12928180264 [3] https://github.com/netblue30/firejail/actions/runs/12928238010 [4] https://github.com/netblue30/firejail/actions/runs/12927984482/attempts/2 [5] https://github.com/netblue30/firejail/actions/runs/12927984482/attempts/3 [6] https://github.com/netblue30/firejail/actions/runs/12927984482/attempts/4 [7] https://github.com/netblue30/firejail/actions/runs/12928180264/job/36054893393 [8] https://github.com/netblue30/firejail/actions/runs/12881736117/job/35912783635
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This makes the compile commands clearer when building in parallel (with
make -j
) and ensures that__FILE__
includes the full build-time path(relative to the root of the repository) whenever it is referenced, such
as in failed assert() messages (currently the full path is only shown in
errExit() messages). Example:
Before:
After:
Commands used to search and replace:
Note: config.mk.in, src/fnettrace/Makefile and src/include/common.h were
edited manually.
This is a follow-up to #5871.