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

Missing symbols when building shared libraries #387

Open
madebr opened this issue Jul 6, 2024 · 0 comments
Open

Missing symbols when building shared libraries #387

madebr opened this issue Jul 6, 2024 · 0 comments

Comments

@madebr
Copy link
Collaborator

madebr commented Jul 6, 2024

When configuring DethRace with -DBUILD_SHARED_LIBS=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON,
linking fails due to missing symbols.

(eventually add -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" to emit an error on missing symbols)

/usr/bin/ld: lib/BRender-v1.3.2/drivers/pentprim/libsoftprmf.so: undefined reference to `TrapezoidRenderPIZ2TIA_RGB_555'
/usr/bin/ld: lib/BRender-v1.3.2/drivers/pentprim/libsoftprmf.so: undefined reference to `TrapezoidRenderPIZ2TIA_RGB_888'
/usr/bin/ld: lib/BRender-v1.3.2/drivers/pentprim/libsoftprmf.so: undefined reference to `TrapezoidRenderPIZ2TAN'
/usr/bin/ld: lib/BRender-v1.3.2/drivers/pentprim/libsoftprmf.so: undefined reference to `ScanLinePITPD64'
/usr/bin/ld: lib/BRender-v1.3.2/drivers/pentprim/libsoftprmf.so: undefined reference to `TrapezoidRenderPITA'
/usr/bin/ld: lib/BRender-v1.3.2/drivers/pentprim/libsoftprmf.so: undefined reference to `ScanLinePITPD1024'
/usr/bin/ld: lib/BRender-v1.3.2/drivers/pentprim/libsoftprmf.so: undefined reference to `TrapezoidRenderPITA24'
/usr/bin/ld: lib/BRender-v1.3.2/drivers/pentprim/libsoftprmf.so: undefined reference to `TrapezoidRenderPITIA'
/usr/bin/ld: lib/BRender-v1.3.2/drivers/pentprim/libsoftprmf.so: undefined reference to `ScanLinePITIPB256_RGB_565'
/usr/bin/ld: lib/BRender-v1.3.2/drivers/pentprim/libsoftprmf.so: undefined reference to `TrapezoidRenderPIZ2TA24'
/usr/bin/ld: lib/BRender-v1.3.2/drivers/pentprim/libsoftprmf.so: undefined reference to `TrapezoidRenderPIZ2TIA'
/usr/bin/ld: lib/BRender-v1.3.2/drivers/pentprim/libsoftprmf.so: undefined reference to `TrapezoidRenderPITAN'
/usr/bin/ld: lib/BRender-v1.3.2/drivers/pentprim/libsoftprmf.so: undefined reference to `TrapezoidRenderPITIA_RGB_555'
/usr/bin/ld: lib/BRender-v1.3.2/drivers/pentprim/libsoftprmf.so: undefined reference to `TrapezoidRenderPIZ2TA15'
/usr/bin/ld: lib/BRender-v1.3.2/drivers/pentprim/libsoftprmf.so: undefined reference to `TrapezoidRenderPITA15'
/usr/bin/ld: lib/BRender-v1.3.2/drivers/pentprim/libsoftprmf.so: undefined reference to `TrapezoidRenderPITIA_RGB_888'
/usr/bin/ld: lib/BRender-v1.3.2/drivers/pentprim/libsoftprmf.so: undefined reference to `ScanLinePITIPB256_RGB_555'
/usr/bin/ld: lib/BRender-v1.3.2/drivers/pentprim/libsoftprmf.so: undefined reference to `TrapezoidRenderPIZ2TA'
/usr/bin/ld: lib/BRender-v1.3.2/drivers/pentprim/libsoftprmf.so: undefined reference to `ScanLinePITPD128'
/usr/bin/ld: lib/BRender-v1.3.2/drivers/pentprim/libsoftprmf.so: undefined reference to `ScanLinePITPD256'
/usr/bin/ld: lib/BRender-v1.3.2/drivers/pentprim/libsoftprmf.so: undefined reference to `ScanLinePITIP256_RGB_555'

We either should disallow building shared libraries, or merge some libraries together.

note:
I had to apply this patch to fix the double definition of _BrDefaultDiagHandler in core/fw/defdiag.c and core/std/defdiag.c.

--- a/core/fw/CMakeLists.txt
+++ b/core/fw/CMakeLists.txt
@@ -75,7 +75,7 @@ set(FW_FILES
         brqsort.c
         bswap.c
         datafile.c
-        defdiag.c
+        # defdiag.c   # core/std/stddiag.c and core/fw/defdiag.c both define _BrDefaultDiagHandler
         deffile.c
         defmem.c
         devlist.c

I think the better fix is to only export public BRender symbols from the shared libraries.
This error occurs because libbrender.so exports _BrDefaultDiagHandler twice, which is not possible.

@madebr madebr changed the title Missing symbols when building shared libraries with -Wl,--no-undefined Missing symbols when building shared libraries Jul 6, 2024
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

No branches or pull requests

1 participant