Skip to content

Fix mistake when setting linker flags#1574

Merged
illwieckz merged 2 commits intomasterfrom
illwieckz/pie
Mar 5, 2025
Merged

Fix mistake when setting linker flags#1574
illwieckz merged 2 commits intomasterfrom
illwieckz/pie

Conversation

@illwieckz
Copy link
Copy Markdown
Member

@illwieckz illwieckz commented Mar 3, 2025

There was a stupid mistake inverting between executable-linker-flags and everythng-linker-flags.

Fixes #1573:

I verified that even after fixing this maCOS still complains about -pie not being used on executables so I kept the macOS test to disable -pie:

[100%] Linking CXX executable daemonded
clang++: warning: argument unused during compilation: '-pie' [-Wunused-command-line-argument]

@illwieckz
Copy link
Copy Markdown
Member Author

illwieckz commented Mar 3, 2025

I also noticed that -pie reruires -fPIC, so since -fPIC is optional, this now tests for this flag being supported before testing for -pie. This is probably useless and this may skip a flag test if -fPIC isn't supported, this should be very rare but this is more consistent when written this way.

$ clang -pie a.cpp && echo done
ld: error: relocation R_X86_64_64 cannot be used against local symbol; recompile with -fPIC
>>> defined in /tmp/a-b05268.o
>>> referenced by a.cpp
>>>               /tmp/a-b05268.o:(main)
clang: error: linker command failed with exit code 1 (use -v to see invocation)

$ clang -fPIC -pie a.cpp && echo done
done

This also fixes an harmless typo.

@illwieckz illwieckz changed the title Illwieckz/pie Fix mistake when setting linker flags Mar 3, 2025
@illwieckz
Copy link
Copy Markdown
Member Author

Thanks for the review!

@illwieckz illwieckz merged commit ed598c3 into master Mar 5, 2025
9 checks passed
@illwieckz illwieckz deleted the illwieckz/pie branch March 5, 2025 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Still getting argument unused during compilation: '-pie' with dll

2 participants