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

Clean up some linker/C compiler options #1916

Merged
merged 1 commit into from
Feb 6, 2025
Merged

Conversation

MaskRay
Copy link
Contributor

@MaskRay MaskRay commented Feb 2, 2025

-fno-pic/-fno-pie/-fpic/-fPIC/-fpie/-fPIE options belong to the same famility where the last option wins. These options have no effect in the link phase.

Clang and GCC usually pass --eh-frame-hdr to ld, with the exception that gcc -static does not pass --eh-frame-hdr. The difference is a historical choice related to __register_frame_info. We can behavle like Clang and always pass --eh-frame-hdr.

Remove a -L that does not specify a directory.

-fno-pic/-fno-pie/-fpic/-fPIC/-fpie/-fPIE options belong to the same
famility where the last option wins. These options have no effect in the
link phase.

Clang and GCC usually pass `--eh-frame-hdr` to ld, with the exception
that `gcc -static` does not pass `--eh-frame-hdr`. The difference is a
historical choice related to `__register_frame_info`. We can behavle
like Clang and always pass `--eh-frame-hdr`.

Remove a `-L` that does not specify a directory.
@MaskRay
Copy link
Contributor Author

MaskRay commented Feb 2, 2025

Side notes (not done in this PR as I am not familiar with the use cases)

@lerno
Copy link
Collaborator

lerno commented Feb 4, 2025

For pie/pic/PIE/PIC here I've tried to follow Clang mostly. I see you removed a bunch of options, but pie and pic are interdependent in Clang what I could note.

@MaskRay
Copy link
Contributor Author

MaskRay commented Feb 5, 2025

For pie/pic/PIE/PIC here I've tried to follow Clang mostly. I see you removed a bunch of options, but pie and pic are interdependent in Clang what I could note.

For -fpic/-fpie/-fno-pic/-fno-pie options the last wins: https://github.com/llvm/llvm-project/blob/05a09e6e559e8253d49cc61052711f0c200129bf/clang/lib/Driver/ToolChains/CommonArgs.cpp#L1907

Regarding the module flags metadata "PIC Level" and "PIE Level". They are independent.

@lerno
Copy link
Collaborator

lerno commented Feb 6, 2025

All right, good!

@lerno lerno merged commit 78dcda0 into c3lang:master Feb 6, 2025
47 checks passed
@lerno
Copy link
Collaborator

lerno commented Feb 6, 2025

Thank you!

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