[v2] Don't combine -r and -export-dynamic linker options

Message ID 20191212175312.343458-1-espindola@scylladb.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] Don't combine -r and -export-dynamic linker options |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation fail apply issues

Commit Message

Rafael Ávila de Espíndola Dec. 12, 2019, 5:53 p.m. UTC
  Running ld with -r switches the linker to a very special mode where
some other linker options don't make sense.

In particular, -export-dynamic normally requires that all global
symbols be included in the dynamic symbol table, but a .o file doesn't
even have a dynamic symbol table.

When given both options it looks like the gnu linker just ignores
-export-dynamic.

Unfortunately some versions of lld (https://lld.llvm.org/) have a bug
that causes it to try to create a dynamic symbol table in the output
.o file and ends up corrupting it
(https://bugs.llvm.org/show_bug.cgi?id=43552). Current (git) version
of lld now issues an error.

This patch filters out -export-dynamic from $(LDFLAGS) when using
-r. With this patch I can build dpdk with lld.

Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>
---
 mk/internal/rte.compile-pre.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Thomas Monjalon Jan. 19, 2020, 10:40 p.m. UTC | #1
12/12/2019 18:53, Rafael Ávila de Espíndola:
> Running ld with -r switches the linker to a very special mode where
> some other linker options don't make sense.
> 
> In particular, -export-dynamic normally requires that all global
> symbols be included in the dynamic symbol table, but a .o file doesn't
> even have a dynamic symbol table.
> 
> When given both options it looks like the gnu linker just ignores
> -export-dynamic.
> 
> Unfortunately some versions of lld (https://lld.llvm.org/) have a bug
> that causes it to try to create a dynamic symbol table in the output
> .o file and ends up corrupting it
> (https://bugs.llvm.org/show_bug.cgi?id=43552). Current (git) version
> of lld now issues an error.
> 
> This patch filters out -export-dynamic from $(LDFLAGS) when using
> -r. With this patch I can build dpdk with lld.
> 
> Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>

Applied, thanks
  

Patch

diff --git a/mk/internal/rte.compile-pre.mk b/mk/internal/rte.compile-pre.mk
index 0cf3791b4..82fe098f7 100644
--- a/mk/internal/rte.compile-pre.mk
+++ b/mk/internal/rte.compile-pre.mk
@@ -61,7 +61,7 @@  CHECK_EXPERIMENTAL = $(EXPERIMENTAL_CHECK) $(SRCDIR)/$(EXPORT_MAP) $@
 
 PMDINFO_GEN = $(RTE_SDK_BIN)/app/dpdk-pmdinfogen $@ $@.pmd.c
 PMDINFO_CC = $(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@.pmd.o $@.pmd.c
-PMDINFO_LD = $(CROSS)ld $(LDFLAGS) -r -o $@.o $@.pmd.o $@
+PMDINFO_LD = $(CROSS)ld -r $(filter-out -export-dynamic,$(LDFLAGS)) -o $@.o $@.pmd.o $@
 PMDINFO_TO_O = if grep -q 'RTE_PMD_REGISTER_.*(.*)' $<; then \
 	echo "$(if $V,$(PMDINFO_GEN),  PMDINFO $@.pmd.c)" && \
 	$(PMDINFO_GEN) && \