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

cmake: linker: lld: add missing -no-pie flag #51900

Merged
merged 1 commit into from
Nov 22, 2022

Conversation

chrta
Copy link
Collaborator

@chrta chrta commented Nov 2, 2022

See also #38903

This is required when building tests for native_posix on ubuntu 22.04 using clang-14 from the normal deb repository.

Signed-off-by: Christian Taedcke [email protected]

See also
zephyrproject-rtos#38903

This is required when building tests for native_posix on ubuntu 22.04 using
clang-14 from the normal deb repository.

Signed-off-by: Christian Taedcke <[email protected]>
@evgeniy-paltsev
Copy link
Collaborator

Hmm, I'm wondering if it's due some changes in clang or it was always broken?

@chrta
Copy link
Collaborator Author

chrta commented Nov 3, 2022

The only thing i noticed is this issue did not occur with zephyr 3.1 using the same build environment. But i don't know for sure if lld was used there (using the default zephyr config when setting ZEPHYR_TOOLCHAIN_VARIANT=llvm).

@@ -11,6 +11,7 @@ macro(toolchain_ld_base)
# TOOLCHAIN_LD_FLAGS comes from compiler/clang/target.cmake
# LINKERFLAGPREFIX comes from linker/lld/target.cmake
zephyr_ld_options(
-no-pie
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think other linkers will need this also? Maybe it should be added to compiler/clang/target.cmake instead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure. I basically copied it from https://github.com/zephyrproject-rtos/zephyr/blob/main/cmake/linker/ld/target_base.cmake#L14 to the same place for lld. But i think it would probably be good to align setting the "-no-pie" option for the compiler and linker in a similar way.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks reasonable to me with the current macro based linker handling we have.

At some point we might we might want to align more to the compiler approach, as in #24851, but that's a different story.

Copy link
Collaborator

@tejlmand tejlmand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@stephanosio stephanosio merged commit 1fde62e into zephyrproject-rtos:main Nov 22, 2022
@chrta chrta deleted the lb-fix-ldd-no-pie branch November 22, 2022 08:26
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.

6 participants