Skip to content

Commit c05d30e

Browse files
committed
[clang][Emscripten] Define __unix family of macros
This will allow us to remove these from the downstream driver: https://github.com/emscripten-core/emscripten/blob/57270ce8150a5107e591b4e9ec7cbeff0ba7c905/emcc.py#L860-L863 Differential Revision: https://reviews.llvm.org/D108735
1 parent 1bdeafe commit c05d30e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

clang/lib/Basic/Targets/OSTargets.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,7 @@ class LLVM_LIBRARY_VISIBILITY EmscriptenTargetInfo
944944
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
945945
MacroBuilder &Builder) const final {
946946
WebAssemblyOSTargetInfo<Target>::getOSDefines(Opts, Triple, Builder);
947+
DefineStd(Builder, "unix", Opts);
947948
Builder.defineMacro("__EMSCRIPTEN__");
948949
if (Opts.POSIXThreads)
949950
Builder.defineMacro("__EMSCRIPTEN_PTHREADS__");

clang/test/Preprocessor/init.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,8 +1847,10 @@
18471847
// WEBASSEMBLY-NEXT:#define __clang_version__ "{{.*}}"
18481848
// WEBASSEMBLY-NEXT:#define __clang_wide_literal_encoding__ {{.*}}
18491849
// WEBASSEMBLY-NEXT:#define __llvm__ 1
1850-
// WEBASSEMBLY-NOT:#define __unix
1851-
// WEBASSEMBLY-NOT:#define __unix__
1850+
// WEBASSEMBLY-WASI-NOT:#define __unix
1851+
// WEBASSEMBLY-WASI-NOT:#define __unix__
1852+
// EMSCRIPTEN-NEXT:#define __unix 1
1853+
// EMSCRIPTEN-NEXT:#define __unix__ 1
18521854
// WEBASSEMBLY-WASI-NEXT:#define __wasi__ 1
18531855
// WEBASSEMBLY-NOT:#define __wasm_simd128__
18541856
// WEBASSEMBLY-NOT:#define __wasm_simd256__
@@ -1863,6 +1865,8 @@
18631865
// WEBASSEMBLY64-NEXT:#define __wasm64 1
18641866
// WEBASSEMBLY64-NEXT:#define __wasm64__ 1
18651867
// WEBASSEMBLY-NEXT:#define __wasm__ 1
1868+
// EMSCRIPTEN:#define unix 1
1869+
// WEBASSEMBLY-WASI-NOT:#define unix 1
18661870
// WEBASSEMBLY-CXX-NOT:_REENTRANT
18671871
// WEBASSEMBLY-CXX-NOT:__STDCPP_THREADS__
18681872
// WEBASSEMBLY-CXX-ATOMICS:#define _REENTRANT 1

0 commit comments

Comments
 (0)