Skip to content

Commit a4d918f

Browse files
authoredDec 12, 2024··
Replace DEFAULT_SYSROOT usage with Clang config files (#503)
Upstream want to deprecate `DEFAULT_SYSROOT`[^1][^2][^3], but one blocker is wasi-sdk's usage of it. Let's try to help that along by switching to using config files[^4] instead. This should result in no user-facing changes in functionality. (If it does, then that's an LLVM bug that should be fixed there.) [^1]: https://reviews.llvm.org/D158218 [^2]: llvm/llvm-project#94284 [^3]: llvm/llvm-project#77537 [^4]: https://clang.llvm.org/docs/UsersManual.html#configuration-files
1 parent ccdf52e commit a4d918f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed
 

‎clang.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--sysroot=<CFGDIR>/../share/wasi-sysroot

‎cmake/wasi-sdk-toolchain.cmake

+12-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ ExternalProject_Add(llvm-build
9090
-DLLVM_DEFAULT_TARGET_TRIPLE=wasm32-wasi
9191
-DLLVM_INSTALL_BINUTILS_SYMLINKS=TRUE
9292
-DLLVM_ENABLE_LIBXML2=OFF
93-
-DDEFAULT_SYSROOT=../share/wasi-sysroot
9493
# Pass `-s` to strip symbols by default and shrink the size of the
9594
# distribution
9695
-DCMAKE_EXE_LINKER_FLAGS=-s
@@ -159,6 +158,18 @@ copy_misc_file(wasi-sdk-p1.cmake cmake)
159158
copy_misc_file(wasi-sdk-p2.cmake cmake)
160159
copy_misc_file(cmake/Platform/WASI.cmake cmake/Platform)
161160

161+
function(copy_cfg_file compiler)
162+
set(dst ${wasi_tmp_install}/bin/${compiler}.cfg)
163+
add_custom_command(
164+
OUTPUT ${dst}
165+
COMMAND cmake -E copy ${CMAKE_CURRENT_SOURCE_DIR}/clang.cfg ${dst})
166+
add_custom_target(copy-${compiler} DEPENDS ${dst})
167+
add_dependencies(misc-files copy-${compiler})
168+
endfunction()
169+
170+
copy_cfg_file(clang)
171+
copy_cfg_file(clang++)
172+
162173
include(wasi-sdk-dist)
163174

164175
# Figure out the name of the artifact which is either explicitly specified or

0 commit comments

Comments
 (0)
Please sign in to comment.