-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[fix] handle spaces in link flags in a portable way #4056
base: dev
Are you sure you want to change the base?
[fix] handle spaces in link flags in a portable way #4056
Conversation
Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
The |
Thank you for looking into this. |
It seems you are already trying to raise some support from the right place, It may be that several lines of |
When testing for support of multiple flags, the flags must be separated by semicolons not spaces. See https://gitlab.kitware.com/cmake/cmake/-/issues/26024 When referenced elsewhere, enclose the flag variable in quotation marks so that it is passed through unmodified. Closes facebook#4056
When testing for support of multiple flags, the flags must be separated by semicolons not spaces. See https://gitlab.kitware.com/cmake/cmake/-/issues/26024 When referenced elsewhere, enclose the flag variable in quotation marks so that it is passed through unmodified. Closes facebook#4056
@@ -76,7 +76,7 @@ macro(ADD_ZSTD_COMPILATION_FLAGS) | |||
endif () | |||
# Add noexecstack flags | |||
# LDFLAGS | |||
EnableCompilerFlag("-z noexecstack" false false true) | |||
EnableCompilerFlag("LINKER:SHELL:-z noexecstack" false false true) |
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.
I'm unfamiliar with LINKER:SHELL:
but the developers' response to the cmake bug report I filed was that multiple flags must be separated by semicolons, not spaces. I submitted #4061 to fix the issue that way instead.
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.
Maybe both fixes are desired.
EnableCompilerFlag
did not support flags containing a space. #4061 fixed that.
I'm unfamiliar with
LINKER:SHELL:
I've now read up on it from the link you provided earlier (https://cmake.org/cmake/help/latest/command/target_link_options.html#command:target_link_options). This sounds like a reasonable way to send flags to the linker, but it seems wrong to me that it should need to be specified when calling EnableCompilerFlag
. It seems like EnableCompilerFlag
should prepend that internally when its fourth argument is true
.
(EnableCompilerFlag
calls CHECK_LINKER_FLAG
and it makes me wonder why CHECK_LINKER_FLAG
doesn't automatically use LINKER:
, but evidently it doesn't; the fact that one could use LINKER:
is even mentioned in the CHECK_LINKER_FLAG
documentation.)
With old versions of gcc, the configure check came to the incorrect conclusion that |
This allows correct detection of linker noexecstack support. When testing for support of multiple flags, the flags must be a list of values separated by semicolons, not a string of values separated by spaces. See https://gitlab.kitware.com/cmake/cmake/-/issues/26024 Enclose the flaglist variable in quotation marks when calling CHECK_*_FLAG so that it is passed through unmodified. After it is determined that a flag is supported, it is still the string version of the flag variable that is appended to the corresponding CMAKE_*_FLAGS variable. Closes facebook#4056
Excuse me, I was describing the problem that was reported to MacPorts and made @MarcusCalhoun-Lopez and me aware of this issue in the first place. A user trying to build zstd with CMake on an old version of macOS with an old version of gcc discovered that the old gcc would silently ignore the unknown single argument Here, in this CI run, I would have to see the contents of CMakeConfigureLog.yaml to be sure, and I didn't see that file saved anywhere by your CI setup, but what I assume is happening is that |
Well, that's not going to work either. What gets used at build time needs to be what was verified to work at configure time. Some linkers (like the GNU linker) support If the configure test uses I don't know how to get that The simplest thing therefore would be what I've done in #4061: Send |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
See: https://cmake.org/cmake/help/latest/command/target_link_options.html#command:target_link_options