diff --git a/clang/docs/ClangOffloadBundler.rst b/clang/docs/ClangOffloadBundler.rst index ebbd502865dab..997948a8217e5 100644 --- a/clang/docs/ClangOffloadBundler.rst +++ b/clang/docs/ClangOffloadBundler.rst @@ -174,20 +174,7 @@ Where: ============= ============================================================== **target-triple** - The target triple of the code object. See `Target Triple - `. - - The bundler accepts target triples with or without the optional environment - field: - - ``--``, or - ``---`` - - However, in order to standardize outputs for tools that consume bitcode - bundles, bundles written by the bundler internally use only the 4-field - target triple: - - ``---`` + The target triple of the code object. **target-id** The canonical target ID of the code object. Present only if the target diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 9506e0cb9a3e4..4e3282cc9e0b6 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -116,19 +116,6 @@ using namespace clang::driver; using namespace clang; using namespace llvm::opt; -// clang-offload-bundler is currently generating a 'standardized' target triple. -// Triple's format - Architecture-Vendor-OS-Environment. -// Bundle sections created by clang-offload-bundler contain the 'standardized' -// triple. This routine transforms the triple specified by user as input to this -// 'standardized' format to facilitate checks. -static std::string standardizedTriple(std::string OrigTriple) { - llvm::Triple t = llvm::Triple(OrigTriple); - return llvm::Triple(t.getArchName(), t.getVendorName(), t.getOSName(), - t.getEnvironmentName()) - .str() + - "-"; -} - static std::optional getOffloadTargetTriple(const Driver &D, const ArgList &Args) { auto OffloadTargets = Args.getAllArgValues(options::OPT_offload_EQ); @@ -6101,20 +6088,9 @@ class OffloadingActionBuilder final { if (Arch.compare(0, 4, "fpga") == 0) Arch = C.getDriver().MakeSYCLDeviceTriple("spir64_fpga").str(); - // The last component for the triple may be a GPU arch - auto TripleOrGPU = StringRef(Arch).rsplit('-'); - if (clang::StringToCudaArch(TripleOrGPU.second.str()) != - clang::CudaArch::UNKNOWN) { - Arch = standardizedTriple(TripleOrGPU.first.str()); - Arch += TripleOrGPU.second.str(); - } else { - Arch = standardizedTriple(Arch); - } - if (std::find(UniqueSections.begin(), UniqueSections.end(), Arch) == - UniqueSections.end()) { + UniqueSections.end()) UniqueSections.push_back(Arch); - } } } @@ -6123,8 +6099,8 @@ class OffloadingActionBuilder final { for (auto &SyclTarget : Targets) { std::string SectionTriple = SyclTarget.TC->getTriple().str(); - SectionTriple = standardizedTriple(SectionTriple); if (SyclTarget.BoundArch) { + SectionTriple += "-"; SectionTriple += SyclTarget.BoundArch; } // If any matching section is found, we are good. diff --git a/clang/lib/Driver/OffloadBundler.cpp b/clang/lib/Driver/OffloadBundler.cpp index 8c47f86223805..b3b8a65bed2fd 100644 --- a/clang/lib/Driver/OffloadBundler.cpp +++ b/clang/lib/Driver/OffloadBundler.cpp @@ -85,25 +85,12 @@ OffloadTargetInfo::OffloadTargetInfo(const StringRef Target, if (clang::StringToCudaArch(TripleOrGPU.second) != clang::CudaArch::UNKNOWN) { auto KindTriple = TripleOrGPU.first.split('-'); this->OffloadKind = KindTriple.first; - - // Enforce optional env field to standardize bundles - llvm::Triple t = llvm::Triple(KindTriple.second); - this->Triple = llvm::Triple(t.getArchName(), t.getVendorName(), - t.getOSName(), t.getEnvironmentName()); - - if (TripleOrGPU.second.empty()) - this->TargetID = ""; - else - this->TargetID = Target.substr(Target.find(TripleOrGPU.second)); + this->Triple = llvm::Triple(KindTriple.second); + this->TargetID = Target.substr(Target.find(TripleOrGPU.second)); } else { auto KindTriple = TargetFeatures.first.split('-'); this->OffloadKind = KindTriple.first; - - // Enforce optional env field to standardize bundles - llvm::Triple t = llvm::Triple(KindTriple.second); - this->Triple = llvm::Triple(t.getArchName(), t.getVendorName(), - t.getOSName(), t.getEnvironmentName()); - + this->Triple = llvm::Triple(KindTriple.second); this->TargetID = ""; } } @@ -1590,34 +1577,34 @@ Error OffloadBundler::UnbundleFiles() { return Error::success(); } -// Unbundle the files. Return false if an error was found. +// Unbundle the files. Return true if an error was found. Expected clang::CheckBundledSection(const OffloadBundlerConfig &BundlerConfig) { // Open Input file. ErrorOr> CodeOrErr = MemoryBuffer::getFileOrSTDIN(BundlerConfig.InputFileNames.front()); if (std::error_code EC = CodeOrErr.getError()) - return false; + return createFileError(BundlerConfig.InputFileNames.front(), EC); MemoryBuffer &Input = *CodeOrErr.get(); // Select the right files handler. Expected> FileHandlerOrErr = CreateFileHandler(Input, BundlerConfig); if (!FileHandlerOrErr) - return false; + return FileHandlerOrErr.takeError(); std::unique_ptr &FH = *FileHandlerOrErr; // Quit if we don't have a handler. if (!FH) - return false; + return true; // Seed temporary filename generation with the stem of the input file. FH->SetTempFileNameBase(llvm::sys::path::stem(BundlerConfig.InputFileNames.front())); // Read the header of the bundled file. if (Error Err = FH->ReadHeader(Input)) - return false; + return std::move(Err); StringRef triple = BundlerConfig.TargetNames.front(); @@ -1628,15 +1615,13 @@ clang::CheckBundledSection(const OffloadBundlerConfig &BundlerConfig) { Expected> CurTripleOrErr = FH->ReadBundleStart(Input); if (!CurTripleOrErr) - return false; + return CurTripleOrErr.takeError(); // We don't have more bundles. if (!*CurTripleOrErr) break; - StringRef CurTriple = **CurTripleOrErr; - if (OffloadTargetInfo(CurTriple, BundlerConfig).Triple.str() == - OffloadTargetInfo(triple, BundlerConfig).Triple.str()) { + if (*CurTripleOrErr == triple) { found = true; break; } diff --git a/clang/test/Driver/Inputs/bundles/bundle_aft_standardization_of_target_triple.o b/clang/test/Driver/Inputs/bundles/bundle_aft_standardization_of_target_triple.o deleted file mode 100644 index f63d320cfb078..0000000000000 Binary files a/clang/test/Driver/Inputs/bundles/bundle_aft_standardization_of_target_triple.o and /dev/null differ diff --git a/clang/test/Driver/Inputs/bundles/bundle_bef_standardization_of_target_triple.o b/clang/test/Driver/Inputs/bundles/bundle_bef_standardization_of_target_triple.o deleted file mode 100644 index d5e4f422f930d..0000000000000 Binary files a/clang/test/Driver/Inputs/bundles/bundle_bef_standardization_of_target_triple.o and /dev/null differ diff --git a/clang/test/Driver/clang-offload-bundler-asserts-on.c b/clang/test/Driver/clang-offload-bundler-asserts-on.c index db99e31d568b9..aceda09f7bfa1 100644 --- a/clang/test/Driver/clang-offload-bundler-asserts-on.c +++ b/clang/test/Driver/clang-offload-bundler-asserts-on.c @@ -21,12 +21,12 @@ // Tests to check compatibility between Bundle Entry ID formats i.e. between presence/absence of extra hyphen in case of missing environment field // RUN: clang-offload-bundler -unbundle -type=a -targets=openmp-amdgcn-amd-amdhsa--gfx906,openmp-amdgcn-amd-amdhsa-gfx908 -input=%t.input-archive.a -output=%t-archive-gfx906-simple.a -output=%t-archive-gfx908-simple.a -debug-only=CodeObjectCompatibility 2>&1 | FileCheck %s -check-prefix=BUNDLECOMPATIBILITY -// BUNDLECOMPATIBILITY: Compatible: Exact match: [CodeObject: openmp-amdgcn-amd-amdhsa--gfx906] : [Target: openmp-amdgcn-amd-amdhsa--gfx906] -// BUNDLECOMPATIBILITY: Compatible: Exact match: [CodeObject: openmp-amdgcn-amd-amdhsa--gfx908] : [Target: openmp-amdgcn-amd-amdhsa--gfx908] +// BUNDLECOMPATIBILITY: Compatible: Exact match: [CodeObject: openmp-amdgcn-amd-amdhsa-gfx906] : [Target: openmp-amdgcn-amd-amdhsa--gfx906] +// BUNDLECOMPATIBILITY: Compatible: Exact match: [CodeObject: openmp-amdgcn-amd-amdhsa--gfx908] : [Target: openmp-amdgcn-amd-amdhsa-gfx908] // RUN: clang-offload-bundler -unbundle -type=a -targets=hip-amdgcn-amd-amdhsa--gfx906,hipv4-amdgcn-amd-amdhsa-gfx908 -input=%t.input-archive.a -output=%t-hip-archive-gfx906-simple.a -output=%t-hipv4-archive-gfx908-simple.a -hip-openmp-compatible -debug-only=CodeObjectCompatibility 2>&1 | FileCheck %s -check-prefix=HIPOpenMPCOMPATIBILITY -// HIPOpenMPCOMPATIBILITY: Compatible: Code Objects are compatible [CodeObject: openmp-amdgcn-amd-amdhsa--gfx906] : [Target: hip-amdgcn-amd-amdhsa--gfx906] -// HIPOpenMPCOMPATIBILITY: Compatible: Code Objects are compatible [CodeObject: openmp-amdgcn-amd-amdhsa--gfx908] : [Target: hipv4-amdgcn-amd-amdhsa--gfx908] +// HIPOpenMPCOMPATIBILITY: Compatible: Code Objects are compatible [CodeObject: openmp-amdgcn-amd-amdhsa-gfx906] : [Target: hip-amdgcn-amd-amdhsa--gfx906] +// HIPOpenMPCOMPATIBILITY: Compatible: Code Objects are compatible [CodeObject: openmp-amdgcn-amd-amdhsa--gfx908] : [Target: hipv4-amdgcn-amd-amdhsa-gfx908] // Some code so that we can create a binary out of this file. int A = 0; diff --git a/clang/test/Driver/clang-offload-bundler-old-bundle-with-new-bundler.c b/clang/test/Driver/clang-offload-bundler-old-bundle-with-new-bundler.c deleted file mode 100644 index 69ad5cc5c8b5e..0000000000000 --- a/clang/test/Driver/clang-offload-bundler-old-bundle-with-new-bundler.c +++ /dev/null @@ -1,10 +0,0 @@ -// REQUIRES: x86-registered-target -// UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}}, system-windows - -// Check working of bundler before and after standardization -// RUN: clang-offload-bundler -type=o -targets=host-x86_64-unknown-linux-gnu,sycl-spir64-unknown-unknown -input=%S/Inputs/bundles/bundle_bef_standardization_of_target_triple.o -output=test-host-x86_64-unknown-linux-gnu.o -output=test-sycl-spir64-unknown-unknown.o -unbundle 2>&1 | FileCheck %s -check-prefix=CHECK-STD-OLD --allow-empty -// CHECK-STD-OLD-NOT: error: Can't find bundles for -// RUN: clang-offload-bundler -type=o -targets=host-x86_64-unknown-linux-gnu,sycl-spir64-unknown-unknown -input=%S/Inputs/bundles/bundle_aft_standardization_of_target_triple.o -output=test-host-x86_64-unknown-linux-gnu.o -output=test-sycl-spir64-unknown-unknown.o -unbundle 2>&1 | FileCheck %s -check-prefix=CHECK-STD-NEW --allow-empty -// CHECK-STD-NEW-NOT: error: Can't find bundles for - - diff --git a/clang/test/Driver/clang-offload-bundler-standardize.c b/clang/test/Driver/clang-offload-bundler-standardize.c deleted file mode 100644 index c9037633761c4..0000000000000 --- a/clang/test/Driver/clang-offload-bundler-standardize.c +++ /dev/null @@ -1,37 +0,0 @@ -// REQUIRES: x86-registered-target -// TODO: remove system-linux when https://github.com/intel/llvm/issues/10238 is -// addressed -// UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}}, system-linux - -// Generate the file we can bundle. -// RUN: %clang -O0 -target %itanium_abi_triple %s -c -o %t.o - -// -// Generate a couple of files to bundle with. -// -// RUN: echo 'Content of device file 1' > %t.tgt1 -// RUN: echo 'Content of device file 2' > %t.tgt2 - -// -// Check code object compatibility for archive unbundling -// -// Create an object bundle with and without env fields -// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,hip-amdgcn-amd-amdhsa-gfx906,hip-amdgcn-amd-amdhsa-gfx908 -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.no.env -// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple-,hip-amdgcn-amd-amdhsa--gfx906,hip-amdgcn-amd-amdhsa--gfx908 -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.env - - -// Unbundle bundle.no.env while providing targets with env -// RUN: clang-offload-bundler -unbundle -type=o -targets=hip-amdgcn-amd-amdhsa--gfx906,hip-amdgcn-amd-amdhsa--gfx908 -input=%t.bundle.no.env -output=%t-hip-amdgcn-amd-amdhsa--gfx906.bc -output=%t-hip-amdgcn-amd-amdhsa--gfx908.bc -debug-only=CodeObjectCompatibility 2>&1 | FileCheck %s -check-prefix=BUNDLE-NO-ENV -// BUNDLE-NO-ENV: Compatible: Exact match: [CodeObject: hip-amdgcn-amd-amdhsa--gfx906] : [Target: hip-amdgcn-amd-amdhsa--gfx906] -// BUNDLE-NO-ENV: Compatible: Exact match: [CodeObject: hip-amdgcn-amd-amdhsa--gfx908] : [Target: hip-amdgcn-amd-amdhsa--gfx908] - -// Unbundle bundle.env while providing targets with no env -// RUN: clang-offload-bundler -unbundle -type=o -targets=hip-amdgcn-amd-amdhsa-gfx906,hip-amdgcn-amd-amdhsa-gfx908 -input=%t.bundle.env -output=%t-hip-amdgcn-amd-amdhsa-gfx906.bc -output=%t-hip-amdgcn-amd-amdhsa-gfx908.bc -debug-only=CodeObjectCompatibility 2>&1 | FileCheck %s -check-prefix=BUNDLE-ENV -// BUNDLE-ENV: Compatible: Exact match: [CodeObject: hip-amdgcn-amd-amdhsa--gfx906] : [Target: hip-amdgcn-amd-amdhsa--gfx906] -// BUNDLE-ENV: Compatible: Exact match: [CodeObject: hip-amdgcn-amd-amdhsa--gfx908] : [Target: hip-amdgcn-amd-amdhsa--gfx908] - -// Some code so that we can create a binary out of this file. -int A = 0; -void test_func(void) { - ++A; -} diff --git a/clang/test/Driver/clang-offload-bundler-tgtsym-asm.c b/clang/test/Driver/clang-offload-bundler-tgtsym-asm.c index c55cd6fd26232..cb9848b8df00e 100644 --- a/clang/test/Driver/clang-offload-bundler-tgtsym-asm.c +++ b/clang/test/Driver/clang-offload-bundler-tgtsym-asm.c @@ -13,8 +13,8 @@ // RUN: llvm-readobj --string-dump=.tgtsym %t.fat.o | FileCheck %s // CHECK: String dump of section '.tgtsym': -// CHECK-DAG: openmp-x86_64-pc-linux-gnu-.foo -// CHECK-DAG: sycl-spir64----.foo +// CHECK-DAG: openmp-x86_64-pc-linux-gnu.foo +// CHECK-DAG: sycl-spir64.foo __asm__(".symver memcpy,memcpy@GLIBC_2.2.5"); void foo(void) {} diff --git a/clang/test/Driver/clang-offload-bundler-tgtsym.c b/clang/test/Driver/clang-offload-bundler-tgtsym.c index eac13b07d2c41..04a65eb0be553 100644 --- a/clang/test/Driver/clang-offload-bundler-tgtsym.c +++ b/clang/test/Driver/clang-offload-bundler-tgtsym.c @@ -12,16 +12,16 @@ // RUN: llvm-readobj --string-dump=.tgtsym %t.fat.o | FileCheck %s // CHECK: String dump of section '.tgtsym': -// CHECK-DAG: openmp-x86_64-pc-linux-gnu-.foo -// CHECK-DAG: openmp-x86_64-pc-linux-gnu-.bar -// CHECK-DAG: sycl-spir64----.foo -// CHECK-DAG: sycl-spir64----.bar +// CHECK-DAG: openmp-x86_64-pc-linux-gnu.foo +// CHECK-DAG: openmp-x86_64-pc-linux-gnu.bar +// CHECK-DAG: sycl-spir64.foo +// CHECK-DAG: sycl-spir64.bar // CHECK-NOT: undefined_func // CHECK-NOT: static_func // CHECK-NOT: static_used -// CHECK-NOT: sycl-spir64----.llvm.used -// CHECK-NOT: sycl-spir64----.llvm.compiler.used -// CHECK-NOT: sycl-spir64----.const_as +// CHECK-NOT: sycl-spir64.llvm.used +// CHECK-NOT: sycl-spir64.llvm.compiler.used +// CHECK-NOT: sycl-spir64.const_as // RUN: clang-offload-bundler --add-target-symbols-to-bundled-object=false -type=o -targets=host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu,sycl-spir64 -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.fat.no.tgtsym.o // RUN: llvm-readobj --string-dump=.tgtsym %t.fat.no.tgtsym.o | FileCheck %s --check-prefix CHECK-NO-TGTSYM diff --git a/clang/test/Driver/clang-offload-bundler.c b/clang/test/Driver/clang-offload-bundler.c index 1d4f24db11b4b..3cd48cab0ab20 100644 --- a/clang/test/Driver/clang-offload-bundler.c +++ b/clang/test/Driver/clang-offload-bundler.c @@ -1,7 +1,6 @@ // REQUIRES: x86-registered-target - -// TODO: Windows-related issue with temporary file creation - Fix and enable -// UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}}, system-windows +// REQUIRES: powerpc-registered-target +// UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}} // // Generate all the types of files we can bundle. @@ -312,11 +311,11 @@ // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \ // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o -DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix CK-OBJ-CMD -// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]" +// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]" // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \ // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o -DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix CK-OBJ-CMD-INPUTS -// CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]" +// CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]" // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o // RUN: clang-offload-bundler -type=o -input=%t.bundle3.o -list | FileCheck -check-prefix=CKLST %s @@ -393,14 +392,15 @@ // RUN: diff %t.tgt2 %t.res.tgt2 // Check archive mode. -// RUN: clang-offload-bundler -type=a -targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.tgt1.a -output=%t.tgt2.a -input=%t.a -unbundle +// RUN: clang-offload-bundler -type=a -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.host.a -output=%t.tgt1.a -output=%t.tgt2.a -input=%t.a -unbundle +// RUN: cmp %t.host.a %t.a // RUN: llvm-ar t %t.tgt1.a | FileCheck %s --check-prefix=CHECK-AR-TGT1-LIST // RUN: llvm-ar t %t.tgt2.a | FileCheck %s --check-prefix=CHECK-AR-TGT2-LIST -// CHECK-AR-TGT1-LIST: openmp-powerpc64le-ibm-linux-gnu-{{.+}}.bundle3.o -// CHECK-AR-TGT1-LIST: openmp-powerpc64le-ibm-linux-gnu-{{.+}}.bundle4.o -// CHECK-AR-TGT2-LIST: openmp-x86_64-pc-linux-gnu-{{.+}}.bundle3.o -// CHECK-AR-TGT2-LIST: openmp-x86_64-pc-linux-gnu-{{.+}}.bundle4.o +// CHECK-AR-TGT1-LIST: openmp-powerpc64le-ibm-linux-gnu.{{.+}}.bundle3.o +// CHECK-AR-TGT1-LIST: openmp-powerpc64le-ibm-linux-gnu.{{.+}}.bundle4.o +// CHECK-AR-TGT2-LIST: openmp-x86_64-pc-linux-gnu.{{.+}}.bundle3.o +// CHECK-AR-TGT2-LIST: openmp-x86_64-pc-linux-gnu.{{.+}}.bundle4.o // // Check error due to missing bundles @@ -547,15 +547,15 @@ // RUN: llvm-ar t %t-archive-gfx906-simple.a | FileCheck %s -check-prefix=GFX906 // RUN: clang-offload-bundler -unbundle -type=a -targets=openmp-amdgcn-amd-amdhsa-gfx906:xnack+ -input=%t.input-archive.a -output=%t-archive-gfx906-simple.a // RUN: llvm-ar t %t-archive-gfx906-simple.a | FileCheck %s -check-prefix=GFX906 -// GFX906: simple-openmp-amdgcn-amd-amdhsa--gfx906 +// GFX906: simple-openmp-amdgcn-amd-amdhsa-gfx906 // RUN: llvm-ar t %t-archive-gfx908-simple.a | FileCheck %s -check-prefix=GFX908 // GFX908-NOT: {{gfx906}} // RUN: not clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-amdgcn-amd-amdhsa-gfx906,openmp-amdgcn-amd-amdhsa-gfx906:sramecc+ -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bad.bundle 2>&1 | FileCheck %s -check-prefix=BADTARGETS -// BADTARGETS: error: Cannot bundle inputs with conflicting targets: 'openmp-amdgcn-amd-amdhsa--gfx906' and 'openmp-amdgcn-amd-amdhsa--gfx906:sramecc+' +// BADTARGETS: error: Cannot bundle inputs with conflicting targets: 'openmp-amdgcn-amd-amdhsa-gfx906' and 'openmp-amdgcn-amd-amdhsa-gfx906:sramecc+' // Check for error if no compatible code object is found in the heterogeneous archive library // RUN: not clang-offload-bundler -unbundle -type=a -targets=openmp-amdgcn-amd-amdhsa-gfx803 -input=%t.input-archive.a -output=%t-archive-gfx803-incompatible.a 2>&1 | FileCheck %s -check-prefix=INCOMPATIBLEARCHIVE -// INCOMPATIBLEARCHIVE: error: no compatible code object found for the target 'openmp-amdgcn-amd-amdhsa--gfx803' in heterogeneous archive library +// INCOMPATIBLEARCHIVE: error: no compatible code object found for the target 'openmp-amdgcn-amd-amdhsa-gfx803' in heterogeneous archive library // Check creation of empty archive if allow-missing-bundles is present and no compatible code object is found in the heterogeneous archive library // RUN: clang-offload-bundler -unbundle -type=a -targets=openmp-amdgcn-amd-amdhsa-gfx803 -input=%t.input-archive.a -output=%t-archive-gfx803-empty.a -allow-missing-bundles @@ -565,7 +565,7 @@ // Check compatibility of OpenMP code objects found in the heterogeneous archive library with HIP code objects of the target // RUN: clang-offload-bundler -unbundle -type=a -targets=hip-amdgcn-amd-amdhsa-gfx906,hipv4-amdgcn-amd-amdhsa-gfx908 -input=%t.input-archive.a -output=%t-hip-archive-gfx906-simple.a -output=%t-hipv4-archive-gfx908-simple.a -hip-openmp-compatible // RUN: llvm-ar t %t-hip-archive-gfx906-simple.a | FileCheck %s -check-prefix=HIPOPENMPCOMPAT -// HIPOPENMPCOMPAT: simple-openmp-amdgcn-amd-amdhsa--gfx906 +// HIPOPENMPCOMPAT: simple-openmp-amdgcn-amd-amdhsa-gfx906 // RUN: llvm-ar t %t-hipv4-archive-gfx908-simple.a | FileCheck %s -check-prefix=HIPv4OPENMPCOMPAT // HIPv4OPENMPCOMPAT: simple-openmp-amdgcn-amd-amdhsa--gfx908 diff --git a/clang/test/Driver/sycl-no-rdc-errors.cpp b/clang/test/Driver/sycl-no-rdc-errors.cpp index 10bae53ace443..3506333efcc9e 100644 --- a/clang/test/Driver/sycl-no-rdc-errors.cpp +++ b/clang/test/Driver/sycl-no-rdc-errors.cpp @@ -5,7 +5,7 @@ // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,sycl-spir64_gen-unknown-unknown -input=%t -input=%t.o -output=%t.fat.o // RUN: not %clang -### -fsycl -fno-sycl-rdc %t.fat.o 2>&1 | FileCheck -check-prefix=CHECK-ARCH %s -// CHECK-ARCH: error: linked binaries do not contain expected 'spir64-unknown-unknown--' target; found targets: 'spir64_gen-unknown-unknown--', this is not supported with '-fno-sycl-rdc' +// CHECK-ARCH: error: linked binaries do not contain expected 'spir64-unknown-unknown' target; found targets: 'spir64_gen-unknown-unknown', this is not supported with '-fno-sycl-rdc' // Some code so that we can create a binary out of this file. void test_func(void) { diff --git a/clang/test/Driver/sycl-target-mismatch.cpp b/clang/test/Driver/sycl-target-mismatch.cpp index a1a1605f532fa..a978b8f7f91e6 100644 --- a/clang/test/Driver/sycl-target-mismatch.cpp +++ b/clang/test/Driver/sycl-target-mismatch.cpp @@ -8,7 +8,7 @@ // RUN: %clangxx -fsycl -fsycl-targets=spir64_gen %S/Inputs/SYCL/objlin64.o \ // RUN: -### %s 2>&1 \ // RUN: | FileCheck %s -check-prefix=SPIR64_GEN_DIAG -// SPIR64_GEN_DIAG: linked binaries do not contain expected 'spir64_gen-unknown-unknown--' target; found targets: 'spir64-unknown-unknown{{.*}}, spir64-unknown-unknown{{.*}}' [-Wsycl-target] +// SPIR64_GEN_DIAG: linked binaries do not contain expected 'spir64_gen-unknown-unknown' target; found targets: 'spir64-unknown-unknown{{.*}}, spir64-unknown-unknown{{.*}}' [-Wsycl-target] // RUN: %clangxx -fsycl -fsycl-targets=spir64 %S/Inputs/SYCL/liblin64.a \ // RUN: -### %s 2>&1 \ @@ -33,7 +33,7 @@ // RUN: %clangxx -fsycl -nocudalib -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --cuda-gpu-arch=sm_60 \ // RUN: %S/Inputs/SYCL/objnvptx64-sm_50.o -### %s 2>&1 \ // RUN: | FileCheck %s -check-prefix=NVPTX64_DIAG -// NVPTX64_DIAG: linked binaries do not contain expected 'nvptx64-nvidia-cuda--sm_60' target; found targets: 'nvptx64-nvidia-cuda--sm_50' [-Wsycl-target] +// NVPTX64_DIAG: linked binaries do not contain expected 'nvptx64-nvidia-cuda-sm_60' target; found targets: 'nvptx64-nvidia-cuda-sm_50' [-Wsycl-target] // RUN: %clangxx -fsycl -nocudalib -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --cuda-gpu-arch=sm_50 \ // RUN: %S/Inputs/SYCL/libnvptx64-sm_50.a -### %s 2>&1 \ @@ -61,7 +61,7 @@ // RUN: %clangxx -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=gfx906 -nogpulib\ // RUN: %S/Inputs/SYCL/objamdgcn-gfx908.o -### %s 2>&1 \ // RUN: | FileCheck %s -check-prefix=AMDGCN_DIAG -// AMDGCN_DIAG: linked binaries do not contain expected 'amdgcn-amd-amdhsa--gfx906' target; found targets: 'amdgcn-amd-amdhsa--gfx908' [-Wsycl-target] +// AMDGCN_DIAG: linked binaries do not contain expected 'amdgcn-amd-amdhsa-gfx906' target; found targets: 'amdgcn-amd-amdhsa-gfx908' [-Wsycl-target] // RUN: %clangxx -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=gfx908 -nogpulib\ // RUN: %S/Inputs/SYCL/libamdgcn-gfx908.a -### %s 2>&1 \ diff --git a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp index c8400ae5cd2e2..6920e1ce86e5a 100644 --- a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp +++ b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp @@ -390,8 +390,6 @@ int main(int argc, const char **argv) { llvm::DenseSet ParsedTargets; // Map {offload-kind}-{triple} to target IDs. std::map> TargetIDs; - // Standardize target names to include env field - std::vector StandardizedTargetNames; for (StringRef Target : TargetNames) { if (ParsedTargets.contains(Target)) { reportError(createStringError(errc::invalid_argument, @@ -403,8 +401,6 @@ int main(int argc, const char **argv) { bool KindIsValid = OffloadInfo.isOffloadKindValid(); bool TripleIsValid = OffloadInfo.isTripleValid(); - StandardizedTargetNames.push_back(OffloadInfo.str()); - if (!KindIsValid || !TripleIsValid) { SmallVector Buf; raw_svector_ostream Msg(Buf); @@ -429,9 +425,6 @@ int main(int argc, const char **argv) { ++Index; } - - BundlerConfig.TargetNames = StandardizedTargetNames; - for (const auto &TargetID : TargetIDs) { if (auto ConflictingTID = clang::getConflictTargetIDCombination(TargetID.second)) { diff --git a/clang/tools/clang-offload-deps/ClangOffloadDeps.cpp b/clang/tools/clang-offload-deps/ClangOffloadDeps.cpp index 979462a91ecd5..835027f8db560 100644 --- a/clang/tools/clang-offload-deps/ClangOffloadDeps.cpp +++ b/clang/tools/clang-offload-deps/ClangOffloadDeps.cpp @@ -74,24 +74,6 @@ static void reportError(Error E) { logAllUnhandledErrors(std::move(E), WithColor::error(errs(), ToolPath)); } -// clang-offload-bundler is currently generating a 'standardized' target header. -// This is of the following form - Kind-Triple-TargetID where triple's format is -// Architecture-Vendor-OS-Environment -// This routine transforms the target header specified by user as input to -// clang-offload-deps to this 'standardized' format. -static std::string standardizedTarget(std::string OrigTarget) { - if (OrigTarget.back() == '-') // Already standardized - return OrigTarget; - StringRef Target(OrigTarget); - auto KindTriple = Target.split('-'); - llvm::Triple t = llvm::Triple(KindTriple.second); - return std::string(KindTriple.first) + "-" + - std::string(llvm::Triple(t.getArchName(), t.getVendorName(), - t.getOSName(), t.getEnvironmentName()) - .str()) + - "-"; -} - int main(int argc, const char **argv) { sys::PrintStackTraceOnErrorSignal(argv[0]); ToolPath = argv[0]; @@ -186,10 +168,11 @@ int main(int argc, const char **argv) { // offload targets and insert them into the map. for (StringRef Symbol = DataOrErr.get(); !Symbol.empty();) { unsigned Len = strlen(Symbol.data()); + // TODO: Consider storing Targets and Kinds in a single map-like struct, // possibly reusing ClangOffloadBundler's 'OffloadTargetInfo'. for (const std::string &Target : Targets) { - std::string Prefix = standardizedTarget(Target) + "."; + std::string Prefix = Target + "."; if (Symbol.startswith(Prefix)) Target2Symbols[Target].insert( Symbol.substr(Prefix.size(), Len - Prefix.size()));