Skip to content

Commit e674424

Browse files
authored
[runtimes] Improve the documentation for LIBCXX_ADDITIONAL_COMPILE_FLAGS (#112733)
This clarifies how that option is meant to be used to avoid confusion. As a drive-by, also fix an incorrect usage in the recently-added GPU caches.
1 parent e2d07fc commit e674424

File tree

5 files changed

+11
-15
lines changed

5 files changed

+11
-15
lines changed

libcxx/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,9 @@ set(LIBCXX_COMPILE_FLAGS "")
456456
set(LIBCXX_LINK_FLAGS "")
457457
set(LIBCXX_LIBRARIES "")
458458
set(LIBCXX_ADDITIONAL_COMPILE_FLAGS "" CACHE STRING
459-
"Additional Compile only flags which can be provided in cache")
459+
"Additional compile flags to use when building libc++. This should be a CMake ;-delimited list of individual
460+
compiler options to use. For options that must be passed as-is to the compiler without deduplication (e.g.
461+
`-Xclang -foo` option groups), consider using `SHELL:` (https://cmake.org/cmake/help/latest/command/add_compile_options.html#option-de-duplication).")
460462
set(LIBCXX_ADDITIONAL_LIBRARIES "" CACHE STRING
461463
"Additional libraries libc++ is linked to which can be provided in cache")
462464

libcxx/cmake/caches/AMDGPU.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ set(LIBCXXABI_USE_LLVM_UNWINDER OFF CACHE BOOL "")
2929

3030
# Necessary compile flags for AMDGPU.
3131
set(LIBCXX_ADDITIONAL_COMPILE_FLAGS
32-
"-nogpulib;-flto;-fconvergent-functions;-Xclang;-mcode-object-version=none" CACHE STRING "")
32+
"-nogpulib;-flto;-fconvergent-functions;SHELL:-Xclang -mcode-object-version=none" CACHE STRING "")
3333
set(LIBCXXABI_ADDITIONAL_COMPILE_FLAGS
34-
"-nogpulib;-flto;-fconvergent-functions;-Xclang;-mcode-object-version=none" CACHE STRING "")
34+
"-nogpulib;-flto;-fconvergent-functions;SHELL:-Xclang -mcode-object-version=none" CACHE STRING "")
3535
set(CMAKE_REQUIRED_FLAGS "-nogpulib" CACHE STRING "")

libcxx/docs/VendorDocumentation.rst

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,13 @@ General purpose options
213213

214214
Output name for the shared libc++ runtime library.
215215

216-
.. option:: LIBCXX_ADDITIONAL_COMPILE_FLAGS:STRING
216+
.. option:: {LIBCXX,LIBCXXABI,LIBUNWIND}_ADDITIONAL_COMPILE_FLAGS:STRING
217217

218218
**Default**: ``""``
219219

220-
Additional Compile only flags which can be provided in cache.
220+
Additional compile flags to use when building the runtimes. This should be a CMake ``;``-delimited list of individual
221+
compiler options to use. For options that must be passed as-is to the compiler without deduplication (e.g.
222+
``-Xclang -foo`` option groups), consider using ``SHELL:`` as `documented here <https://cmake.org/cmake/help/latest/command/add_compile_options.html#option-de-duplication>`_.
221223

222224
.. option:: LIBCXX_ADDITIONAL_LIBRARIES:STRING
223225

@@ -346,12 +348,6 @@ The following options allow building libc++ for a different ABI version.
346348
Build and use the LLVM unwinder. Note: This option can only be used when
347349
libc++abi is the C++ ABI library used.
348350

349-
.. option:: LIBCXXABI_ADDITIONAL_COMPILE_FLAGS:STRING
350-
351-
**Default**: ``""``
352-
353-
Additional Compile only flags which can be provided in cache.
354-
355351
.. option:: LIBCXXABI_ADDITIONAL_LIBRARIES:STRING
356352

357353
**Default**: ``""``

libcxxabi/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,7 @@ set(LIBCXXABI_CXX_FLAGS "")
222222
set(LIBCXXABI_COMPILE_FLAGS "")
223223
set(LIBCXXABI_LINK_FLAGS "")
224224
set(LIBCXXABI_LIBRARIES "")
225-
set(LIBCXXABI_ADDITIONAL_COMPILE_FLAGS "" CACHE STRING
226-
"Additional Compile only flags which can be provided in cache")
225+
set(LIBCXXABI_ADDITIONAL_COMPILE_FLAGS "" CACHE STRING "See documentation LIBCXX_ADDITIONAL_COMPILE_FLAGS")
227226
set(LIBCXXABI_ADDITIONAL_LIBRARIES "" CACHE STRING
228227
"Additional libraries libc++abi is linked to which can be provided in cache")
229228

libunwind/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,7 @@ set(LIBUNWIND_C_FLAGS "")
162162
set(LIBUNWIND_CXX_FLAGS "")
163163
set(LIBUNWIND_COMPILE_FLAGS "")
164164
set(LIBUNWIND_LINK_FLAGS "")
165-
set(LIBUNWIND_ADDITIONAL_COMPILE_FLAGS "" CACHE STRING
166-
"Additional Compile only flags which can be provided in cache")
165+
set(LIBUNWIND_ADDITIONAL_COMPILE_FLAGS "" CACHE STRING "See documentation for LIBCXX_ADDITIONAL_COMPILE_FLAGS")
167166
set(LIBUNWIND_ADDITIONAL_LIBRARIES "" CACHE STRING
168167
"Additional libraries libunwind is linked to which can be provided in cache")
169168

0 commit comments

Comments
 (0)