Skip to contentSkip to conversation

tools/testing/cxl: Don't wrap cxl_core's own exported symbols

PATCH Applied Richard Cheng 4 participants 6 messages Jul 21 – Sep 1 CXL

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/testing/cxl: Don't wrap cxl_core's own exported symbols

Building cxl_test with LLVM=1 (ld.lld) fails in modpost:

"""
cxl_core: .export_symbol section references '__wrap_...', but it does not seem to be an export symbol
"""

cxl_test --wraps 6 symbols that cxl_core both defines and exports. GNU ld only wraps undefined references, but ld.lld also redirects references to defined symbols, so cxl_core's own EXPORT_SYMBOL entries get rewritten to __wrap_* and modpost rejects them.

cxl_core never calls these symbols, so wrap them only in the caller modules via LDFLAGS_<module>.o instead of the global ldflags-y.

---
 tools/testing/cxl/Kbuild | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
tools/testing/cxl/Kbuild +10 -6
index 2be1df80fcc9..e49ce644b4b1 100644
@@ -4,16 +4,20 @@ ldflags-y += --wrap=is_acpi_device_node
 ldflags-y += --wrap=acpi_evaluate_integer
 ldflags-y += --wrap=acpi_pci_find_root
 ldflags-y += --wrap=nvdimm_bus_register
-ldflags-y += --wrap=cxl_await_media_ready
-ldflags-y += --wrap=devm_cxl_add_rch_dport
-ldflags-y += --wrap=cxl_endpoint_parse_cdat
-ldflags-y += --wrap=devm_cxl_endpoint_decoders_setup
 ldflags-y += --wrap=hmat_get_extended_linear_cache_size
-ldflags-y += --wrap=devm_cxl_add_dport_by_dev
-ldflags-y += --wrap=devm_cxl_switch_port_decoders_setup
 ldflags-y += --wrap=walk_hmem_resources
 ldflags-y += --wrap=region_intersects
 ldflags-y += --wrap=region_intersects_soft_reserve
+wrap_cxl_core := --wrap=cxl_await_media_ready
+wrap_cxl_core += --wrap=devm_cxl_add_rch_dport
+wrap_cxl_core += --wrap=devm_cxl_add_dport_by_dev
+wrap_cxl_core += --wrap=devm_cxl_switch_port_decoders_setup
+wrap_cxl_core += --wrap=devm_cxl_endpoint_decoders_setup
+wrap_cxl_core += --wrap=cxl_endpoint_parse_cdat
+LDFLAGS_cxl_acpi.o += $(wrap_cxl_core)
+LDFLAGS_cxl_pmem.o += $(wrap_cxl_core)
+LDFLAGS_cxl_port.o += $(wrap_cxl_core)
+LDFLAGS_cxl_mem.o  += $(wrap_cxl_core)
 
 DRIVERS := ../../../drivers
 DAX_HMEM_SRC := $(DRIVERS)/dax/hmem
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Richard Cheng

Building cxl_test with LLVM=1 (ld.lld) fails in modpost:

"""
cxl_core: .export_symbol section references '__wrap_...', but it does not seem to be an export symbol
"""

cxl_test --wraps 6 symbols that cxl_core both defines and exports. GNU ld only wraps undefined references, but ld.lld also redirects references to defined symbols, so cxl_core's own EXPORT_SYMBOL entries get rewritten to __wrap_* and modpost rejects them.

Quoted 4 lines

cxl_core never calls these symbols, so wrap them only in the caller modules via LDFLAGS_<module>.o instead of the global ldflags-y.

Quoted 35 lines
---
 tools/testing/cxl/Kbuild | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
tools/testing/cxl/Kbuild +10 -6
index 2be1df80fcc9..e49ce644b4b1 100644
@@ -4,16 +4,20 @@ ldflags-y += --wrap=is_acpi_device_node
 ldflags-y += --wrap=acpi_evaluate_integer
 ldflags-y += --wrap=acpi_pci_find_root
 ldflags-y += --wrap=nvdimm_bus_register
-ldflags-y += --wrap=cxl_await_media_ready
-ldflags-y += --wrap=devm_cxl_add_rch_dport
-ldflags-y += --wrap=cxl_endpoint_parse_cdat
-ldflags-y += --wrap=devm_cxl_endpoint_decoders_setup
 ldflags-y += --wrap=hmat_get_extended_linear_cache_size
-ldflags-y += --wrap=devm_cxl_add_dport_by_dev
-ldflags-y += --wrap=devm_cxl_switch_port_decoders_setup
 ldflags-y += --wrap=walk_hmem_resources
 ldflags-y += --wrap=region_intersects
 ldflags-y += --wrap=region_intersects_soft_reserve
+wrap_cxl_core := --wrap=cxl_await_media_ready
+wrap_cxl_core += --wrap=devm_cxl_add_rch_dport
+wrap_cxl_core += --wrap=devm_cxl_add_dport_by_dev
+wrap_cxl_core += --wrap=devm_cxl_switch_port_decoders_setup
+wrap_cxl_core += --wrap=devm_cxl_endpoint_decoders_setup
+wrap_cxl_core += --wrap=cxl_endpoint_parse_cdat
+LDFLAGS_cxl_acpi.o += $(wrap_cxl_core)
+LDFLAGS_cxl_pmem.o += $(wrap_cxl_core)
+LDFLAGS_cxl_port.o += $(wrap_cxl_core)
+LDFLAGS_cxl_mem.o  += $(wrap_cxl_core)
 
 DRIVERS := ../../../drivers
 DAX_HMEM_SRC := $(DRIVERS)/dax/hmem
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Richard Cheng
Quoted 7 lines · Richard Cheng

Building cxl_test with LLVM=1 (ld.lld) fails in modpost:

"""
cxl_core: .export_symbol section references '__wrap_...', but it does not seem to be an export symbol
"""

Quoted 7 lines

cxl_test --wraps 6 symbols that cxl_core both defines and exports. GNU ld only wraps undefined references, but ld.lld also redirects references to defined symbols, so cxl_core's own EXPORT_SYMBOL entries get rewritten to __wrap_* and modpost rejects them.

cxl_core never calls these symbols, so wrap them only in the caller modules via LDFLAGS_<module>.o instead of the global ldflags-y.

Tested-by on v1 1/1
#3 lore raw
In reply to Richard Cheng
Quoted 54 lines · Richard Cheng

Building cxl_test with LLVM=1 (ld.lld) fails in modpost:

"""
cxl_core: .export_symbol section references '__wrap_...', but it does not seem to be an export symbol
"""

cxl_test --wraps 6 symbols that cxl_core both defines and exports. GNU ld only wraps undefined references, but ld.lld also redirects references to defined symbols, so cxl_core's own EXPORT_SYMBOL entries get rewritten to __wrap_* and modpost rejects them.

cxl_core never calls these symbols, so wrap them only in the caller modules via LDFLAGS_<module>.o instead of the global ldflags-y.

---
 tools/testing/cxl/Kbuild | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
tools/testing/cxl/Kbuild +10 -6
index 2be1df80fcc9..e49ce644b4b1 100644
@@ -4,16 +4,20 @@ ldflags-y += --wrap=is_acpi_device_node
 ldflags-y += --wrap=acpi_evaluate_integer
 ldflags-y += --wrap=acpi_pci_find_root
 ldflags-y += --wrap=nvdimm_bus_register
-ldflags-y += --wrap=cxl_await_media_ready
-ldflags-y += --wrap=devm_cxl_add_rch_dport
-ldflags-y += --wrap=cxl_endpoint_parse_cdat
-ldflags-y += --wrap=devm_cxl_endpoint_decoders_setup
 ldflags-y += --wrap=hmat_get_extended_linear_cache_size
-ldflags-y += --wrap=devm_cxl_add_dport_by_dev
-ldflags-y += --wrap=devm_cxl_switch_port_decoders_setup
 ldflags-y += --wrap=walk_hmem_resources
 ldflags-y += --wrap=region_intersects
 ldflags-y += --wrap=region_intersects_soft_reserve
+wrap_cxl_core := --wrap=cxl_await_media_ready
+wrap_cxl_core += --wrap=devm_cxl_add_rch_dport
+wrap_cxl_core += --wrap=devm_cxl_add_dport_by_dev
+wrap_cxl_core += --wrap=devm_cxl_switch_port_decoders_setup
+wrap_cxl_core += --wrap=devm_cxl_endpoint_decoders_setup
+wrap_cxl_core += --wrap=cxl_endpoint_parse_cdat
+LDFLAGS_cxl_acpi.o += $(wrap_cxl_core)
+LDFLAGS_cxl_pmem.o += $(wrap_cxl_core)
+LDFLAGS_cxl_port.o += $(wrap_cxl_core)
+LDFLAGS_cxl_mem.o  += $(wrap_cxl_core)
 
 DRIVERS := ../../../drivers
 DAX_HMEM_SRC := $(DRIVERS)/dax/hmem
Signature · 1 line
2.43.0

Hi Richard,

I was hitting the same tools/testing/cxl build failure on current cxl/next. modpost was failing on wrapped CXL symbols, for example:

.export_symbol section references '__wrap_devm_cxl_add_rch_dport', but it does not seem to be an export symbol

.export_symbol section references '__wrap_devm_cxl_add_dport_by_dev', but it does not seem to be an export symbol

.export_symbol section references '__wrap_cxl_await_media_ready', but it does not seem to be an export symbol

I found this patch while investigating the failure and applied it to my tree. With the patch applied, the wrapped-symbol build issue is resolved and tools/testing/cxl builds successfully for me.

#4 lore raw
Quoted 67 lines · shaikh kamaluddin
Quoted 54 lines · Richard Cheng

Building cxl_test with LLVM=1 (ld.lld) fails in modpost:

"""
cxl_core: .export_symbol section references '__wrap_...', but it does not seem to be an export symbol
"""

cxl_test --wraps 6 symbols that cxl_core both defines and exports. GNU ld only wraps undefined references, but ld.lld also redirects references to defined symbols, so cxl_core's own EXPORT_SYMBOL entries get rewritten to __wrap_* and modpost rejects them.

cxl_core never calls these symbols, so wrap them only in the caller modules via LDFLAGS_<module>.o instead of the global ldflags-y.

---
 tools/testing/cxl/Kbuild | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
tools/testing/cxl/Kbuild +10 -6
index 2be1df80fcc9..e49ce644b4b1 100644
@@ -4,16 +4,20 @@ ldflags-y += --wrap=is_acpi_device_node
 ldflags-y += --wrap=acpi_evaluate_integer
 ldflags-y += --wrap=acpi_pci_find_root
 ldflags-y += --wrap=nvdimm_bus_register
-ldflags-y += --wrap=cxl_await_media_ready
-ldflags-y += --wrap=devm_cxl_add_rch_dport
-ldflags-y += --wrap=cxl_endpoint_parse_cdat
-ldflags-y += --wrap=devm_cxl_endpoint_decoders_setup
 ldflags-y += --wrap=hmat_get_extended_linear_cache_size
-ldflags-y += --wrap=devm_cxl_add_dport_by_dev
-ldflags-y += --wrap=devm_cxl_switch_port_decoders_setup
 ldflags-y += --wrap=walk_hmem_resources
 ldflags-y += --wrap=region_intersects
 ldflags-y += --wrap=region_intersects_soft_reserve
+wrap_cxl_core := --wrap=cxl_await_media_ready
+wrap_cxl_core += --wrap=devm_cxl_add_rch_dport
+wrap_cxl_core += --wrap=devm_cxl_add_dport_by_dev
+wrap_cxl_core += --wrap=devm_cxl_switch_port_decoders_setup
+wrap_cxl_core += --wrap=devm_cxl_endpoint_decoders_setup
+wrap_cxl_core += --wrap=cxl_endpoint_parse_cdat
+LDFLAGS_cxl_acpi.o += $(wrap_cxl_core)
+LDFLAGS_cxl_pmem.o += $(wrap_cxl_core)
+LDFLAGS_cxl_port.o += $(wrap_cxl_core)
+LDFLAGS_cxl_mem.o  += $(wrap_cxl_core)
 
 DRIVERS := ../../../drivers
 DAX_HMEM_SRC := $(DRIVERS)/dax/hmem
Signature · 1 line
2.43.0

Hi Richard,

I was hitting the same tools/testing/cxl build failure on current cxl/next. modpost was failing on wrapped CXL symbols, for example:

.export_symbol section references '__wrap_devm_cxl_add_rch_dport', but it does not seem to be an export symbol

.export_symbol section references '__wrap_devm_cxl_add_dport_by_dev', but it does not seem to be an export symbol

Quoted 8 lines

.export_symbol section references '__wrap_cxl_await_media_ready', but it does not seem to be an export symbol

I found this patch while investigating the failure and applied it to my tree. With the patch applied, the wrapped-symbol build issue is resolved and tools/testing/cxl builds successfully for me.

Hi Shaikh,

Happy to hear that, appreciate for this.

Best regards,
Richard Cheng.

maintainer Applied
#5 lore raw
In reply to Richard Cheng
Quoted 12 lines · Richard Cheng

Building cxl_test with LLVM=1 (ld.lld) fails in modpost:

"""
cxl_core: .export_symbol section references '__wrap_...', but it does not seem to be an export symbol
"""

cxl_test --wraps 6 symbols that cxl_core both defines and exports. GNU ld only wraps undefined references, but ld.lld also redirects references to defined symbols, so cxl_core's own EXPORT_SYMBOL entries get rewritten to __wrap_* and modpost rejects them.

Quoted 4 lines

cxl_core never calls these symbols, so wrap them only in the caller modules via LDFLAGS_<module>.o instead of the global ldflags-y.

Applied to cxl/next
2c73cda8908f

Quoted 35 lines
---
 tools/testing/cxl/Kbuild | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
tools/testing/cxl/Kbuild +10 -6
index 2be1df80fcc9..e49ce644b4b1 100644
@@ -4,16 +4,20 @@ ldflags-y += --wrap=is_acpi_device_node
 ldflags-y += --wrap=acpi_evaluate_integer
 ldflags-y += --wrap=acpi_pci_find_root
 ldflags-y += --wrap=nvdimm_bus_register
-ldflags-y += --wrap=cxl_await_media_ready
-ldflags-y += --wrap=devm_cxl_add_rch_dport
-ldflags-y += --wrap=cxl_endpoint_parse_cdat
-ldflags-y += --wrap=devm_cxl_endpoint_decoders_setup
 ldflags-y += --wrap=hmat_get_extended_linear_cache_size
-ldflags-y += --wrap=devm_cxl_add_dport_by_dev
-ldflags-y += --wrap=devm_cxl_switch_port_decoders_setup
 ldflags-y += --wrap=walk_hmem_resources
 ldflags-y += --wrap=region_intersects
 ldflags-y += --wrap=region_intersects_soft_reserve
+wrap_cxl_core := --wrap=cxl_await_media_ready
+wrap_cxl_core += --wrap=devm_cxl_add_rch_dport
+wrap_cxl_core += --wrap=devm_cxl_add_dport_by_dev
+wrap_cxl_core += --wrap=devm_cxl_switch_port_decoders_setup
+wrap_cxl_core += --wrap=devm_cxl_endpoint_decoders_setup
+wrap_cxl_core += --wrap=cxl_endpoint_parse_cdat
+LDFLAGS_cxl_acpi.o += $(wrap_cxl_core)
+LDFLAGS_cxl_pmem.o += $(wrap_cxl_core)
+LDFLAGS_cxl_port.o += $(wrap_cxl_core)
+LDFLAGS_cxl_mem.o  += $(wrap_cxl_core)
 
 DRIVERS := ../../../drivers
 DAX_HMEM_SRC := $(DRIVERS)/dax/hmem