Skip to content

Commit

Permalink
[Driver] Check the environment version except wasm case. (#80783)
Browse files Browse the repository at this point in the history
Add isWasm() check for here:
#78655 (comment)
  • Loading branch information
ZijunZhaoCCK committed Feb 6, 2024
1 parent 4d8e849 commit fbded66
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
20 changes: 11 additions & 9 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1443,16 +1443,18 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
const ToolChain &TC = getToolChain(
*UArgs, computeTargetTriple(*this, TargetTriple, *UArgs));

// Check if the environment version is valid.
// Check if the environment version is valid except wasm case.
llvm::Triple Triple = TC.getTriple();
StringRef TripleVersionName = Triple.getEnvironmentVersionString();
StringRef TripleObjectFormat =
Triple.getObjectFormatTypeName(Triple.getObjectFormat());
if (Triple.getEnvironmentVersion().empty() && TripleVersionName != "" &&
TripleVersionName != TripleObjectFormat) {
Diags.Report(diag::err_drv_triple_version_invalid)
<< TripleVersionName << TC.getTripleString();
ContainsError = true;
if (!Triple.isWasm()) {
StringRef TripleVersionName = Triple.getEnvironmentVersionString();
StringRef TripleObjectFormat =
Triple.getObjectFormatTypeName(Triple.getObjectFormat());
if (Triple.getEnvironmentVersion().empty() && TripleVersionName != "" &&
TripleVersionName != TripleObjectFormat) {
Diags.Report(diag::err_drv_triple_version_invalid)
<< TripleVersionName << TC.getTripleString();
ContainsError = true;
}
}

// Report warning when arm64EC option is overridden by specified target
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,18 @@
// RUN: FileCheck --check-prefix=CHECK-TARGET %s

// CHECK-TARGET: "aarch64-unknown-linux-android31"

// RUN: not %clang --target=armv7-linux-gnuS -c %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-ERROR2 %s

// CHECK-ERROR2: error: version 'S' in target triple 'armv7-unknown-linux-gnuS' is invalid

// RUN: %clang --target=wasm32-unknown-wasi-preview2 -c %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-WASM %s

// CHECK-WASM: "-triple" "wasm32-unknown-wasi-preview2"

// RUN: %clang --target=wasm32-wasi-pthread -c %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-WASM1 %s

// CHECK-WASM1: "-triple" "wasm32-unknown-wasi-pthread"

0 comments on commit fbded66

Please sign in to comment.