Skip to content

Commit 16c0e34

Browse files
[NativeAOT-LLVM] Clean up WASI build (#3149)
* Clean up WASI build * More python workarounds
1 parent 9c2e987 commit 16c0e34

File tree

6 files changed

+10
-126
lines changed

6 files changed

+10
-126
lines changed

eng/native/configurecompiler.cmake

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,6 @@ elseif (CLR_CMAKE_HOST_UNIX)
142142
# Use uppercase CMAKE_BUILD_TYPE for the string comparisons below
143143
string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_CMAKE_BUILD_TYPE)
144144

145-
if(CLR_CMAKE_HOST_BROWSER OR CLR_CMAKE_HOST_WASI)
146-
# The emscripten build has additional warnings so -Werror breaks
147-
add_compile_options(-Wno-unused-parameter)
148-
add_compile_options(-Wno-alloca)
149-
add_compile_options(-Wno-implicit-int-float-conversion)
150-
endif()
151-
152145
if (CMAKE_USE_PTHREADS AND CLR_CMAKE_HOST_BROWSER)
153146
add_compile_options(-pthread)
154147
endif(CMAKE_USE_PTHREADS AND CLR_CMAKE_HOST_BROWSER)
@@ -523,7 +516,7 @@ endif ()
523516
#--------------------------------------
524517
# Compile Options
525518
#--------------------------------------
526-
if (CLR_CMAKE_HOST_UNIX)
519+
if (CLR_CMAKE_HOST_UNIX OR CLR_CMAKE_HOST_WASI)
527520
# Disable frame pointer optimizations so profilers can get better call stacks
528521
add_compile_options(-fno-omit-frame-pointer)
529522

@@ -701,16 +694,7 @@ if (CLR_CMAKE_HOST_UNIX)
701694
endif()
702695
endif(CLR_CMAKE_HOST_MACCATALYST)
703696

704-
endif(CLR_CMAKE_HOST_UNIX)
705-
706-
if(CLR_CMAKE_HOST_WASI)
707-
# TODO-LLVM: deduplicate with the suppressions above (WASI is not "Unix").
708-
add_compile_options(-Wno-unused-variable)
709-
add_compile_options(-Wno-unused-value)
710-
add_compile_options(-Wno-unused-function)
711-
add_compile_options(-Wno-tautological-compare)
712-
add_compile_options(-Wno-invalid-offsetof)
713-
endif()
697+
endif(CLR_CMAKE_HOST_UNIX OR CLR_CMAKE_HOST_WASI)
714698

715699
if(CLR_CMAKE_TARGET_UNIX)
716700
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_UNIX>)
@@ -751,12 +735,7 @@ if(CLR_CMAKE_TARGET_UNIX)
751735
endif()
752736
elseif(CLR_CMAKE_TARGET_WASI)
753737
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_WASI>)
754-
if (CLR_CMAKE_TARGET_OS STREQUAL wasi)
755-
add_definitions(-D_WASI_EMULATED_PROCESS_CLOCKS -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_GETPID -D_GNU_SOURCE)
756-
# no-unsafe-buffer-usage for pal_random.c
757-
# no-unused-macros for _version.c
758-
add_compile_options(-Wno-deprecated-declarations -Wno-unsafe-buffer-usage -Wno-unused-macros)
759-
endif ()
738+
add_compile_definitions(_WASI_EMULATED_PROCESS_CLOCKS _WASI_EMULATED_SIGNAL _WASI_EMULATED_GETPID _GNU_SOURCE)
760739
else(CLR_CMAKE_TARGET_UNIX)
761740
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_WINDOWS>)
762741
endif(CLR_CMAKE_TARGET_UNIX)

src/coreclr/nativeaot/Bootstrap/base/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ set_target_properties(bootstrapper PROPERTIES OUTPUT_NAME bootstrapper)
99

1010
install_bootstrapper_object(bootstrapper aotsdk)
1111

12-
if (CLR_CMAKE_HOST_UNIX)
12+
if (CLR_CMAKE_HOST_UNIX OR CLR_CMAKE_HOST_WASI)
1313
add_library(stdc++compat STATIC ../stdcppshim.cpp)
1414
install_static_library(stdc++compat aotsdk nativeaot)
1515
endif()

src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ The .NET Foundation licenses this file to you under the MIT license.
620620

621621
<ItemGroup Condition="'$(_targetOS)' == 'wasi'" >
622622
<CustomLinkerArg Include="@(_CustomLinkerArgExport->'-Wl,--export=%(Identity)')" />
623-
<CustomLinkerArg Include="-lstdc++;-lwasi-emulated-process-clocks;-lwasi-emulated-signal;-lwasi-emulated-mman;-lwasi-emulated-getpid" />
623+
<CustomLinkerArg Include="-lstdc++;-lwasi-emulated-process-clocks;-lwasi-emulated-signal;-lwasi-emulated-mman;-lwasi-emulated-getpid;-lwasi-emulated-pthread" />
624624
<CustomLinkerArg Include="-Wl,--max-memory=2147483648" />
625625
<CustomLinkerArg Include="-Wl,--global-base=$(IlcWasmGlobalBase)" />
626626
<CustomLinkerArg Include="-Wl,-z,stack-size=$(IlcWasmStackSize)" />

src/coreclr/nativeaot/Runtime/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,6 @@ else()
137137

138138
include(${GC_DIR}/unix/configure.cmake)
139139

140-
if(CLR_CMAKE_TARGET_ARCH_WASM)
141-
include_directories($ENV{EMSCRIPTEN/system/lib/libcxxabi/include})
142-
endif()
143-
144140
# Disable building _Unwind_XXX style APIs of libunwind, since we don't use them.
145141
add_definitions(-D_LIBUNWIND_DISABLE_ZERO_COST_APIS=1)
146142

src/coreclr/nativeaot/Runtime/wasm/PalRedhawkWasm.cpp

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -46,102 +46,6 @@ void PalGetMaximumStackBounds_SingleThreadedWasm(void** ppStackLowOut, void** pp
4646
}
4747

4848
#ifdef TARGET_WASI
49-
// No-op stubs that assume a single-threaded environment.
50-
int pthread_mutex_init(pthread_mutex_t *, const pthread_mutexattr_t *)
51-
{
52-
return 0;
53-
}
54-
55-
int pthread_mutexattr_init(pthread_mutexattr_t *)
56-
{
57-
return 0;
58-
}
59-
60-
int pthread_mutexattr_settype(pthread_mutexattr_t *, int)
61-
{
62-
return 0;
63-
}
64-
65-
int pthread_mutex_destroy(pthread_mutex_t *)
66-
{
67-
return 0;
68-
}
69-
70-
int pthread_mutexattr_destroy(pthread_mutexattr_t *)
71-
{
72-
return 0;
73-
}
74-
75-
int pthread_cond_init(pthread_cond_t *, const pthread_condattr_t *)
76-
{
77-
return 0;
78-
}
79-
80-
int pthread_cond_destroy(pthread_cond_t *)
81-
{
82-
return 0;
83-
}
84-
85-
int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *)
86-
{
87-
return 0;
88-
}
89-
90-
int pthread_cond_timedwait(pthread_cond_t *, pthread_mutex_t *, const struct timespec *)
91-
{
92-
return 0;
93-
}
94-
95-
int pthread_condattr_init(pthread_condattr_t *)
96-
{
97-
return 0;
98-
}
99-
100-
int pthread_mutex_lock(pthread_mutex_t *)
101-
{
102-
return 0;
103-
}
104-
105-
int pthread_mutex_unlock(pthread_mutex_t *)
106-
{
107-
return 0;
108-
}
109-
110-
pthread_t pthread_self(void)
111-
{
112-
return (pthread_t)0;
113-
}
114-
115-
int pthread_equal(pthread_t, pthread_t)
116-
{
117-
return 1; // only one thread
118-
}
119-
120-
int pthread_attr_init(pthread_attr_t *)
121-
{
122-
return 0;
123-
}
124-
125-
int pthread_attr_destroy(pthread_attr_t *)
126-
{
127-
return 0;
128-
}
129-
130-
int pthread_condattr_destroy(pthread_condattr_t *)
131-
{
132-
return 0;
133-
}
134-
135-
int pthread_cond_broadcast(pthread_cond_t *)
136-
{
137-
return 0;
138-
}
139-
140-
int pthread_attr_setdetachstate(pthread_attr_t *, int)
141-
{
142-
return 0;
143-
}
144-
14549
using Dtor = void(*)(void*);
14650

14751
// Due to a bug in the toolchain, we have to provide an implementation of thread-local destruction.

src/coreclr/vm/eventing/EtwProvider/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
include(FindPython)
22

3+
# Workaround from https://github.com/dotnet/runtime/pull/117513
4+
if (NOT "$ENV{EMSDK_PYTHON}" STREQUAL "")
5+
set(Python_EXECUTABLE "$ENV{EMSDK_PYTHON}")
6+
endif()
7+
38
set(ETW_PROVIDER_SCRIPT ${CLR_DIR}/scripts/genEtwProvider.py)
49

510
set (ETW_PROVIDER_OUTPUTS

0 commit comments

Comments
 (0)