Skip to content

Commit

Permalink
Replace DEFAULT_SYSROOT usage with Clang config files (#503)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
carlocab authored Dec 12, 2024
1 parent ccdf52e commit a4d918f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions clang.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sysroot=<CFGDIR>/../share/wasi-sysroot
13 changes: 12 additions & 1 deletion cmake/wasi-sdk-toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ ExternalProject_Add(llvm-build
-DLLVM_DEFAULT_TARGET_TRIPLE=wasm32-wasi
-DLLVM_INSTALL_BINUTILS_SYMLINKS=TRUE
-DLLVM_ENABLE_LIBXML2=OFF
-DDEFAULT_SYSROOT=../share/wasi-sysroot
# Pass `-s` to strip symbols by default and shrink the size of the
# distribution
-DCMAKE_EXE_LINKER_FLAGS=-s
Expand Down Expand Up @@ -159,6 +158,18 @@ copy_misc_file(wasi-sdk-p1.cmake cmake)
copy_misc_file(wasi-sdk-p2.cmake cmake)
copy_misc_file(cmake/Platform/WASI.cmake cmake/Platform)

function(copy_cfg_file compiler)
set(dst ${wasi_tmp_install}/bin/${compiler}.cfg)
add_custom_command(
OUTPUT ${dst}
COMMAND cmake -E copy ${CMAKE_CURRENT_SOURCE_DIR}/clang.cfg ${dst})
add_custom_target(copy-${compiler} DEPENDS ${dst})
add_dependencies(misc-files copy-${compiler})
endfunction()

copy_cfg_file(clang)
copy_cfg_file(clang++)

include(wasi-sdk-dist)

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

0 comments on commit a4d918f

Please sign in to comment.