Skip to content

Commit

Permalink
Add support for triple wasm32-unknown-emscripten (#4672)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanEngelen committed May 25, 2024
1 parent c497e0a commit e136a05
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions driver/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,9 @@ void registerPredefinedTargetVersions() {
VersionCondition::addPredefinedGlobalIdent("WASI");
VersionCondition::addPredefinedGlobalIdent("CRuntime_WASI");
break;
case llvm::Triple::Emscripten:
VersionCondition::addPredefinedGlobalIdent("Emscripten");
break;
default:
if (triple.getEnvironment() == llvm::Triple::Android) {
VersionCondition::addPredefinedGlobalIdent("Android");
Expand Down
11 changes: 11 additions & 0 deletions tests/codegen/wasm_emscripten.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// REQUIRES: target_WebAssembly

// RUN: %ldc -mtriple=wasm32-unknown-emscripten -w -output-ll -of=%t.ll %s
// RUN: FileCheck %s < %t.ll

// test predefined versions:
version (Emscripten) {} else static assert(0);

void foo() {}

// CHECK: target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20"

0 comments on commit e136a05

Please sign in to comment.