Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
TOPDIR ?= $(APPDIR)/import
-include $(TOPDIR)/Make.defs

# Send the emulated TLS calls of loadable modules and of the programs of a
# kernel build to libc (EMUTLS_LDFLAGS: see tools/Config.mk of NuttX)

LDELFFLAGS += $(EMUTLS_LDFLAGS)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why not modify the initialization of LDELFFLAG directly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

EMUTLS_LDFLAGS comes from tools/Config.mk, but Config.mk is included before the arch Toolchain.defs, which sets LDELFFLAGS and LDMODULEFLAGS with =, so Config.mk cannot add to them. After Toolchain.defs, 28 board Make.defs files set them again with = (for example boards/arm/stm32h7/openh743i/scripts/Make.defs:49, boards/arm/samv7/samv71-xult/configs/knsh/Make.defs:59, boards/arm64/imx9/imx95-a55-evk/scripts/Make.defs:45, boards/renesas/rx65n/rx65n/scripts/Make.defs:59, boards/sim/sim/sim/scripts/Make.defs:273,304), and tools/mkexport.sh:243 sets LDMODULEFLAGS="-r" for the export. To do it in NuttX, I must change the Toolchain.defs of every arch that can use emulated TLS, these board files and mkexport.sh. apps Make.defs is the first place after all of them, so the two lines here cover every board and the export.

If you prefer the NuttX side, I can first remove the board lines that only repeat the arch values (some point to binfmt/elf/gnu-elf.ld, which is gone) in a separate PR, and then add $(EMUTLS_LDFLAGS) where Toolchain.defs sets the two variables. Is this what you want?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yes, it's better to initialize the flag with the correct value instead patch them later.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in apache/nuttx#20723: the arch Toolchain.defs (and the sim Make.defs) now adds EMUTLS_LDFLAGS to LDELFFLAGS and LDMODULEFLAGS, and mkexport.sh keeps it in the export. With apps master, a module that uses __thread now links to __wrap___emutls_get_address of libc (tlsgroup: PASS on qemu-armv8a:nsh), and the export of qemu-armv8a:knsh has the options. apps needs no change, so I close this PR. The boards that set these variables again in their Make.defs are cleaned up in apache/nuttx#20844.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

let's add this special flag in nuttx when we define LDELFFLAGS

LDMODULEFLAGS += $(EMUTLS_LDFLAGS)

# Application Directories

# BUILDIRS is the list of top-level directories containing Make.defs files
Expand Down
Loading