Skip to content
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

Update how wasi-sdk uses cmake #161

Merged
merged 9 commits into from
Dec 1, 2020
Merged

Conversation

sunfishcode
Copy link
Member

Change CMAKE_SYSTEM_NAME to WASI, use a CMAKE_MODULE_PATH,
remove CACHE usage, and fix the compiler autodetection code so that
the "compiler works" hacks are no longer needed, following the advice in
this comment.

This is hopefully a step towards re-submitting WASI support to upstream cmake.

Makefile Outdated
# run the compiler to see if it produces working binaries succeed.
mkdir -p $(PREFIX)/lib/clang/$(CLANG_VERSION)/lib/wasi
$(AR) cr $(PREFIX)/share/wasi-sysroot/lib/wasm32-wasi/libc++.a
$(AR) cr $(PREFIX)/share/wasi-sysroot/lib/wasm32-wasi/libc++abi.a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little gross.. but I don't know that right way to bootstrap here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think its slightly better to do -DCMAKE_C_COMPILER_WORKS=ON on the command line here. Basically saying "we are bootstrapping here so skip compiler checks".

Doing it in the wasi-sdk.cmake globally was wrong but going it locally is not so bad IMHO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that idea. I've now updated the PR to do this, and removed all the empty-archive hacks.

@@ -155,6 +157,8 @@ build/libcxx.BUILT: build/llvm.BUILT build/compiler-rt.BUILT build/wasi-libc.BUI

# Flags for libcxxabi.
LIBCXXABI_CMAKE_FLAGS = \
-DCMAKE_C_COMPILER_WORKS=ON \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh.. looks like these were already specified below!

Change `CMAKE_SYSTEM_NAME` to `WASI`, use a `CMAKE_MODULE_PATH`,
remove `CACHE` usage, and fix the compiler autodetection code so that
the "compiler works" hacks are no longer needed, following the advice in
[this comment](https://gitlab.kitware.com/cmake/cmake/-/issues/19223#note_567327).

This is hopefully a step towards re-submitting WASI support to upstream cmake.
This ensures that it finds the built sysroot when testing whether the C
compiler works.
compiler-rt depends on some libc headers, so it needs a sysroot.
@sunfishcode sunfishcode force-pushed the sunfishcode/cmake-module-path branch from fc51f5f to 985879e Compare November 30, 2020 21:30
It appears with the removal of the AR checks cmake is no longer
autodetecting CMAKE_AR, so set it explicitly.
@sunfishcode sunfishcode merged commit 2cd26ea into master Dec 1, 2020
@sunfishcode sunfishcode deleted the sunfishcode/cmake-module-path branch December 1, 2020 03:44
kildom pushed a commit to kildom/clang-wasi-port that referenced this pull request Jul 14, 2021
alexcrichton pushed a commit to alexcrichton/wasi-sdk that referenced this pull request Apr 5, 2023
This change was mostly generated by changing the upstream llvm
branch to 9.x and running:

  $ git submodule update --remote

As well as switching the llvm 9 this change also bring in the
following wasi-libc changes:

  5933c20 fix macos filename, use https
  7c39519 CI: upgrade to llvm 9.0.0
  9ca5187 remove no-self-update workaround for windows azure
  9580a25 deprecate azure pipelines CI, build libc on GH Actions
  2c2fc9a Don't call `free` on paths which are about to call `_Exit`. (WebAssembly#161)
  c6f2c05 gen-headers: Generate assertions of layout from witx (WebAssembly#149)
  37c663f Correct minor typo in c_headers.rs (WebAssembly#166)
  12f5832 Convert more wasi-libc code to `//`-style comments. (WebAssembly#153)
  ec86d4d Improvements to wasi-headers tool (WebAssembly#160)
  1fad338 Fix environment variable init to exit successfully. (WebAssembly#159)
  a280fea Move math source files. (WebAssembly#151)
  dd010be Avoid using cast expressions in WASI API constants. (WebAssembly#148)

Fixes: WebAssembly#101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants