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

data symbols in Windows shared library #237

Open
loriab opened this issue Feb 9, 2022 · 0 comments
Open

data symbols in Windows shared library #237

loriab opened this issue Feb 9, 2022 · 0 comments

Comments

@loriab
Copy link
Collaborator

loriab commented Feb 9, 2022

Building a dll on Windows with BUILD_SHARED_LIBS=ON works just fine. Both bin/int2.dll and lib/int2.lib are installed. But when one links to the library like in the hartree-fock++ test case, missing symbols errors appear. Using the relevant CMake property WINDOWS_EXPORT_ALL_SYMBOLS clears up symbols like libint2_cleanup_default and libint2_need_memory_1emultipole but still errors on the symbols below. Looking at the symbols in a Linux library with nm, the ones that are still problematic are the B (uninitialized data section) ones, not the T (text (code) section) ones. Since data symbols are what the CMake property won't handle (see link above), I suspect that the libint_build_* definitions need __declspec(dllexport)/__declspec(dllimport) in the generated L2 library source to make the Windows dll useable.

I'd be glad if someone gave the "decl-ing" a try — I don't want to attempt this over CI. I would like this to be working for the future Windows c-f conda package, but at the moment, this issue is an FYI (possibly misdiagnosed), not an impediment.

2022-02-09T14:57:28.8212847Z [2/2] Linking CXX executable hf++.exe
2022-02-09T14:57:28.8213849Z FAILED: hf++.exe 
2022-02-09T14:57:28.8221349Z cmd.exe /C "cd . && C:\Miniconda\envs\test\Library\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\hf++.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x64\mt.exe --manifests  -- C:\PROGRA~1\LLVM\bin\lld-link.exe /nologo CMakeFiles\hf++.dir\D_\a\libint\libint\libint\tests\hartree-fock\hartree-fock++.cc.obj  /out:hf++.exe /implib:hf++.lib /pdb:hf++.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console  D:\a\libint\libint\installed\lib\int2.lib  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
2022-02-09T14:57:28.8223980Z LINK: command "C:\PROGRA~1\LLVM\bin\lld-link.exe /nologo CMakeFiles\hf++.dir\D_\a\libint\libint\libint\tests\hartree-fock\hartree-fock++.cc.obj /out:hf++.exe /implib:hf++.lib /pdb:hf++.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console D:\a\libint\libint\installed\lib\int2.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:hf++.exe.manifest" failed (exit code 1) with the following output:
2022-02-09T14:57:28.8226292Z lld-link: error: undefined symbol: libint2_build_1emultipole
2022-02-09T14:57:28.8229203Z >>> referenced by CMakeFiles\hf++.dir\D_\a\libint\libint\libint\tests\hartree-fock\hartree-fock++.cc.obj:(private: void __cdecl libint2::Engine::_initialize(void))
2022-02-09T14:57:28.8230025Z ...
2022-02-09T14:57:28.8230444Z lld-link: error: undefined symbol: libint2_build_elecpot1
2022-02-09T14:57:28.8232267Z lld-link: error: undefined symbol: libint2_build_overlap1
2022-02-09T14:57:28.8237943Z lld-link: error: undefined symbol: libint2_build_kinetic1
2022-02-09T14:57:28.8277884Z lld-link: error: undefined symbol: libint2_build_1emultipole1
2022-02-09T14:57:28.8282387Z lld-link: error: undefined symbol: libint2_build_2emultipole1
2022-02-09T14:57:28.8283839Z lld-link: error: undefined symbol: libint2_build_2emultipole
2022-02-09T14:57:28.8305037Z lld-link: error: undefined symbol: libint2_build_3emultipole1
2022-02-09T14:57:28.8306567Z lld-link: error: undefined symbol: libint2_build_3emultipole
2022-02-09T14:57:28.8308082Z lld-link: error: undefined symbol: libint2_build_elecpot
2022-02-09T14:57:28.8309739Z lld-link: error: undefined symbol: libint2_build_overlap
2022-02-09T14:57:28.8311160Z lld-link: error: undefined symbol: libint2_build_kinetic
2022-02-09T14:57:28.8314037Z lld-link: error: undefined symbol: libint2_build_sphemultipole1
2022-02-09T14:57:28.8316019Z lld-link: error: undefined symbol: libint2_build_sphemultipole
2022-02-09T14:57:28.8318689Z lld-link: error: undefined symbol: libint2_build_3eri1
2022-02-09T14:57:28.8322221Z lld-link: error: undefined symbol: libint2_build_eri1
2022-02-09T14:57:28.8323604Z lld-link: error: undefined symbol: libint2_build_default
2022-02-09T14:57:28.8325154Z lld-link: error: undefined symbol: libint2_build_3eri
2022-02-09T14:57:28.8328701Z lld-link: error: undefined symbol: libint2_build_eri
2022-02-09T14:57:28.8329457Z >>> referenced by CMakeFiles\hf++.dir\D_\a\libint\libint\libint\tests\hartree-fock\hartree-fock++.cc.obj:(private: void __cdecl libint2::Engine::_initialize(void))
2022-02-09T14:57:28.8330171Z ninja: build stopped: subcommand failed.
2022-02-09T14:57:28.8343899Z ##[error]Process completed with exit code 1.
2022-02-09T14:57:28.8487126Z Cleaning up orphan processes
> nm install-25/lib64/libint2.so | grep libint2_ | grep overlap
00000000000a47c0 B libint2_build_overlap
00000000000a4520 B libint2_build_overlap1
0000000000019350 T libint2_cleanup_overlap
0000000000019430 T libint2_cleanup_overlap1
0000000000018ad0 T libint2_init_overlap
0000000000018f30 T libint2_init_overlap1
0000000000018820 T libint2_need_memory_overlap
0000000000018970 T libint2_need_memory_overlap1

Added: use REQUIRE_CXX_API_COMPILED=OFF to defer the error to linking int2.dll to L2 consumer, which is testable, rather than getting it at engine.cpp to int2.dll link time.

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