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

stl/CMakeLists.txt: Rerunning CMake relinks msvcp140_atomic_wait_oss.dll unnecessarily #2605

Closed
StephanTLavavej opened this issue Mar 12, 2022 · 1 comment · Fixed by #2606
Labels
build Related to the build system fixed Something works now, yay!

Comments

@StephanTLavavej
Copy link
Member

msvcp140_atomic_wait_oss.dll depends on a generated file:

STL/stl/CMakeLists.txt

Lines 505 to 513 in 4bb41db

# generate the .def for msvcp140_atomic_wait.dll
set(_ATOMIC_WAIT_OUTPUT_NAME "msvcp140${D_SUFFIX}_atomic_wait${VCLIBS_SUFFIX}")
string(TOUPPER "${_ATOMIC_WAIT_OUTPUT_NAME}" _ATOMIC_WAIT_OUTPUT_NAME_UPPER)
set(_ATOMIC_WAIT_DEF_NAME "${CMAKE_BINARY_DIR}/msvcp_atomic_wait${D_SUFFIX}.def")
set(_ATOMIC_WAIT_DEF_FILE_SRC "${CMAKE_CURRENT_LIST_DIR}/src/msvcp_atomic_wait.src")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${_ATOMIC_WAIT_DEF_FILE_SRC}")
file(READ "${_ATOMIC_WAIT_DEF_FILE_SRC}" _ATOMIC_WAIT_SRC_CONTENTS)
string(REPLACE "LIBRARYNAME" "${_ATOMIC_WAIT_OUTPUT_NAME_UPPER}" _ATOMIC_WAIT_DEF_CONTENTS "${_ATOMIC_WAIT_SRC_CONTENTS}")
file(WRITE "${_ATOMIC_WAIT_DEF_NAME}" "${_ATOMIC_WAIT_DEF_CONTENTS}")

We're replacing this text:

LIBRARY LIBRARYNAME

After building, rerunning ninja alone is fine:

D:\GitHub\STL>cmake -G Ninja -S . -B out\build\x64 && ninja -C out\build\x64
[...]
[977/977] Linking CXX static library out\lib\amd64\libcpmtd.lib

D:\GitHub\STL>ninja -C out\build\x64
ninja: Entering directory `out\build\x64'
ninja: no work to do.

However, rerunning cmake followed by ninja performs an unnecessary relink:

D:\GitHub\STL>cmake -G Ninja -S . -B out\build\x64 && ninja -C out\build\x64
[...]
[2/2] Linking CXX shared library out\bin\amd64\msvcp140_atomic_wait_oss.dll

@cbezault says that add_custom_command might be the cleanest way to do this.

We should avoid changing the content of msvcp_atomic_wait.src as the internal build system also needs to consume this file (and changing that is a headache).

@StephanTLavavej StephanTLavavej added the build Related to the build system label Mar 12, 2022
@AlexGuteniev
Copy link
Contributor

Maybe give up on that and go to __declspec(dllexport) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Related to the build system fixed Something works now, yay!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants