-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[compiler-rt][CMake] Pass all flags to _Float16 try-compile #133952
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
Conversation
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.
Unrelated to this change but I see string(REPLACE ";" " " _TARGET_${arch}_CFLAGS "${TARGET_${arch}_CFLAGS}")
below, which I think could just be dropped and we use CMAKE_REQUIRED_FLASG instead?
The try-compile mechanism requires that `CMAKE_REQUIRED_FLAGS` is a space-separated string instead of a list of flags. The original code expanded BUILTIN_FLAGS into CMAKE_REQUIRED_FLAGS as a space-separated string and then would overwrite CMAKE_REQUIRED_FLAGS with TARGET_${arch}_CFLAGS prepended to the unexpanded BUILTIN_CFLAGS_${arch}. This resulted in the first two arguments being passed into the try-compile invocation, but dropping the other arguments listed in BUILTIN_CFLAGS_${arch}. This patch takes the contents of both TARGET_${arch}_CLFAGS and BUILTIN_FLAGS_${arch}, combines them into a single list, and then joins that list as a space-separated string in `CMAKE_REQUIRED_FLAGS`.
`TARGET_${arch}_CFLAGS` is expanded into `CMAKE_REQUIRED_FLAGS`, which is implicitly added to the flags by `check_compile_definition`. We don't need to re-expand the `TARGET_${arch}_CFLAGS` variable again.
ac4e25c
to
4e29148
Compare
Even better, it looks like llvm-project/compiler-rt/cmake/Modules/CompilerRTUtils.cmake Lines 94 to 103 in 1edb6b0
I've dropped adding those arguments entirely and it's only adding |
set(CMAKE_REQUIRED_FLAGS ${BUILTIN_CFLAGS_${arch}} ${TARGET_${arch}_CFLAGS}) | ||
list(JOIN CMAKE_REQUIRED_FLAGS " " CMAKE_REQUIRED_FLAGS) |
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.
This is going to overwrite CMAKE_REQUIRED_FLAGS
set by parent directories. Instead, we should be concatenating the flags.
set(CMAKE_REQUIRED_FLAGS ${BUILTIN_CFLAGS_${arch}} ${TARGET_${arch}_CFLAGS}) | |
list(JOIN CMAKE_REQUIRED_FLAGS " " CMAKE_REQUIRED_FLAGS) | |
set(BUILTIN_CFLAGS ${BUILTIN_CFLAGS_${arch}} ${TARGET_${arch}_CFLAGS}) | |
list(JOIN BUILTIN_CFLAGS " " BUILTIN_CFLAGS) | |
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${BUILTIN_CFLAGS}") |
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.
The original behavior also did not include existing CMAKE_REQUIRED_FLAGS
. Fixed.
The original behavior also omitted any existing required flags. Patch this to include them in the _Float16 support check.
) The try-compile mechanism requires that `CMAKE_REQUIRED_FLAGS` is a space-separated string instead of a list of flags. The original code expanded `BUILTIN_FLAGS` into `CMAKE_REQUIRED_FLAGS` as a space-separated string and then would overwrite `CMAKE_REQUIRED_FLAGS` with `TARGET_${arch}_CFLAGS` prepended to the unexpanded `BUILTIN_CFLAGS_${arch}`. This resulted in the first two arguments being passed into the try-compile invocation, but dropping the other arguments listed in `BUILTIN_CFLAGS_${arch}`. This patch appends `TARGET_${arch}_CFLAGS` and `BUILTIN_CFLAGS_${arch}` to `CMAKE_REQUIRED_FLAGS` before expanding CMAKE_REQUIRED_FLAGS as a space-separated string. This passes any pre-set required flags, in addition to all of the builtin and target flags to the Float16 detection. (cherry picked from commit 0d3f5ec)
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/17/builds/7033 Here is the relevant piece of the build log for the reference
|
) The try-compile mechanism requires that `CMAKE_REQUIRED_FLAGS` is a space-separated string instead of a list of flags. The original code expanded `BUILTIN_FLAGS` into `CMAKE_REQUIRED_FLAGS` as a space-separated string and then would overwrite `CMAKE_REQUIRED_FLAGS` with `TARGET_${arch}_CFLAGS` prepended to the unexpanded `BUILTIN_CFLAGS_${arch}`. This resulted in the first two arguments being passed into the try-compile invocation, but dropping the other arguments listed in `BUILTIN_CFLAGS_${arch}`. This patch appends `TARGET_${arch}_CFLAGS` and `BUILTIN_CFLAGS_${arch}` to `CMAKE_REQUIRED_FLAGS` before expanding CMAKE_REQUIRED_FLAGS as a space-separated string. This passes any pre-set required flags, in addition to all of the builtin and target flags to the Float16 detection. (cherry picked from commit 0d3f5ec) (cherry picked from commit e958952)
The try-compile mechanism requires that
CMAKE_REQUIRED_FLAGS
is a space-separated string instead of a list of flags. The original code expandedBUILTIN_FLAGS
intoCMAKE_REQUIRED_FLAGS
as a space-separated string and then would overwriteCMAKE_REQUIRED_FLAGS
withTARGET_${arch}_CFLAGS
prepended to the unexpandedBUILTIN_CFLAGS_${arch}
. This resulted in the first two arguments being passed into the try-compile invocation, but dropping the other arguments listed inBUILTIN_CFLAGS_${arch}
.This patch appends
${TARGET_${arch}_CFLAGS}
to the list, and then joins the elements with spaces, resulting in all arguments passed viaCMAKE_REQUIRED_FLAGS
being space-separated and being used in the try-compile when detecting Float16.