-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[lit] Use CMAKE_C_FLAGS and CMAKE_EXE_LINKER_FLAGS when compiling test plugin #70136
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
[lit] Use CMAKE_C_FLAGS and CMAKE_EXE_LINKER_FLAGS when compiling test plugin #70136
Conversation
…t plugin In cases where the swift-plugin-server is built with specialized `CMAKE_C_FLAGS` and/or `CMAKE_EXE_LINKER_FLAGS`, if one wants to load a plugin in it, one needs to build with a compatible set of flags, or the plugin will not be able to be loaded. Most of the time the tests can build against the `/` sysroot and be fine, but in the case of these test plugins, since they have to be loaded into the swift-plugin-server process, they need to compiled and linked in a compatible way. Using `CMAKE_C_FLAGS` and `CMAKE_EXE_LINKER_FLAGS` uses the same set of flags in both cases, and allow loading these test plugins during testing and avoid failures. The change in `lit.site.cfg.in` embeds the values of `CMAKE_C_FLAGS` and `CMAKE_EXE_LINKER_FLAGS` from CMake into the Lit configuration. The usage of raw triple quoted strings allow single and double quoted arguments to survive the interpolation. The change in `lit.local.cfg` creates two substitutions for them, and uses those substitutions in `swift-build-cxx-plugin`.
@swift-ci please test |
@compnerd I don't know if you want a similar change in the Windows branch. It seems to work for the Windows builds, so not sure if they need this extra flexibility. |
Do you know specifically what flags are causing issues here? |
In our case, we compile |
Ah, yes, that is a good point - we should match the host configuration for the tests. We get away with it on Windows because we don't have cross-compilation against different versions atm. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense 👍 Thanks @drodriguez
@@ -25,6 +25,8 @@ else: | |||
0, | |||
( | |||
'%swift-build-cxx-plugin', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes me think swift-build-cxx-plugin
is the wrong name, since it's not C++ 😅.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want that change, I would prefer doing it in a different PR. It involves changing a lot of "callsites".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's fine, I just noticed because you added C_FLAGS and I was about to comment with "CXX_FLAGS?".
As pointed out in swiftlang#70136 (comment) the substitution name does not make sense because we are compiling C code, not C++. This should not introduce any behavioural changes.
As pointed out in swiftlang#70136 (comment) the substitution name does not make sense because we are compiling C code, not C++. This should not introduce any behavioural changes.
…0188) As pointed out in #70136 (comment) the substitution name does not make sense because we are compiling C code, not C++. This should not introduce any behavioural changes.
@drodriguez |
Probably related. Do you prefer to revert and I will try to investigate ASan problems? It will take me a while to build an ASan build, I am afraid. |
FYI, tests are disabled in ASAN #70206 |
The plugin failed with:
|
|
Apparently this is because |
Thanks for all the clues. I am still in 1509/2444 when building the ASAN preset. Maybe the trick is trying to match If I understand https://github.com/apple/swift/blob/a7a0b329f21bf036cf65ebf073af8773b03eb934/cmake/modules/AddSwift.cmake#L149C4-L149C43 correctly, it might happen that I will keep waiting for the build to finish to be able to test theories on the actual compiled code. |
Yeah, I will open a PR to fix it. Basically, I will expose |
…iftlang#70188) As pointed out in swiftlang#70136 (comment) the substitution name does not make sense because we are compiling C code, not C++. This should not introduce any behavioural changes.
In cases where the swift-plugin-server is built with specialized
CMAKE_C_FLAGS
and/orCMAKE_EXE_LINKER_FLAGS
, if one wants to load a plugin in it, one needs to build with a compatible set of flags, or the plugin will not be able to be loaded.Most of the time the tests can build against the
/
sysroot and be fine, but in the case of these test plugins, since they have to be loaded into the swift-plugin-server process, they need to compiled and linked in a compatible way. UsingCMAKE_C_FLAGS
andCMAKE_EXE_LINKER_FLAGS
uses the same set of flags in both cases, and allow loading these test plugins during testing and avoid failures.The change in
lit.site.cfg.in
embeds the values ofCMAKE_C_FLAGS
andCMAKE_EXE_LINKER_FLAGS
from CMake into the Lit configuration. The usage of raw triple quoted strings allow single and double quoted arguments to survive the interpolation.The change in
lit.local.cfg
creates two substitutions for them, and uses those substitutions inswift-build-cxx-plugin
.