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

[Driver] Check the environment version except wasm case. #80783

Merged
merged 5 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
ZijunZhaoCCK marked this conversation as resolved.
Show resolved Hide resolved

// 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"