ltcmelo / psychec

A compiler frontend for the C programming language
BSD 3-Clause "New" or "Revised" License
536 stars 39 forks source link

Creating per-library EXPORT symbols #44

Closed aytey closed 3 years ago

aytey commented 3 years ago

Makes the changes as discussed here:

I should note that this still doesn't work though (it does create cnip.exe though!) due to link failures in test-suite.exe:

<lots>
D:/DEV/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/test-suite.dir/tests/TestRunner.cpp.o:TestRunner.cpp:(.rdata$.refptr._ZN3psy1C10TestParser8case0002Ev[.refptr._ZN3psy1C10TestParser8case0002Ev]+0x0): undefined reference to `psy::C::TestParser::case0002()'
D:/DEV/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/test-suite.dir/tests/TestRunner.cpp.o:TestRunner.cpp:(.rdata$.refptr._ZN3psy1C10TestParser8case0001Ev[.refptr._ZN3psy1C10TestParser8case0001Ev]+0x0): undefined reference to `psy::C::TestParser::case0001()'
D:/DEV/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/test-suite.dir/tests/TestRunner.cpp.o:TestRunner.cpp:(.rdata$.refptr._ZTVN3psy1C10TestParserE[.refptr._ZTVN3psy1C10TestParserE]+0x0): undefined reference to `vtable for psy::C::TestParser'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Signed-off-by: Andrew V. Jones andrew.jones@vector.com

aytey commented 3 years ago

Yeah, I have no idea why the test implementations go into psychecfe.{so,dll} -- it probably makes sense this "doesn't work", because things like TestBinder aren't dllexport'd.

aytey commented 3 years ago

If you're happy, I can just if out (in the top-level CMakeLists.txt) building the tests on Windows:

-set(PSYCHE_TESTS test-suite)
-add_executable(${PSYCHE_TESTS} ${PSYCHE_TESTS_SOURCES})
-target_link_libraries(${PSYCHE_TESTS} psychecfe psychecommon dl)
+IF (NOT WIN32 AND NOT MINGW)
+    set(PSYCHE_TESTS test-suite)
+    add_executable(${PSYCHE_TESTS} ${PSYCHE_TESTS_SOURCES})
+    target_link_libraries(${PSYCHE_TESTS} psychecfe psychecommon dl)
+endif()

This then successfully builds for me.

ltcmelo commented 3 years ago

Thank you @andrewvaughanj !

ltcmelo commented 3 years ago

Feel free to add this.