Author: Lucas Duarte Prates Date: 2024-10-07T08:56:17+01:00 New Revision: da759dda58a7a1cbdaace26c381e1c3c5c5491ce
URL: https://github.com/llvm/llvm-project/commit/da759dda58a7a1cbdaace26c381e1c3c5c5491ce DIFF: https://github.com/llvm/llvm-project/commit/da759dda58a7a1cbdaace26c381e1c3c5c5491ce.diff LOG: [Clang][Driver] Add option to provide path for multilib's YAML config file (#109640) Since the introduction of the use of a YAML file to configure the selection of multilibs for baremetal, the path for that file has been hardcoded into the clang driver code. This makes it difficult to provide any alternative configurations for multilib and, by consequence, impacts the tetability of any changes related to it - e.g. the existing multilib YAML tests currently rely on creating fake toolchain directories to inject their own configuration files. This change introduces a new command line option to the clang driver, `--multi-lib-config=`, to enable the use of a custom path to be used when loading the multilib YAML config file. It also updates the existing multilib YAML tests to use the new option. Added: clang/test/Driver/Inputs/multilib/empty.yaml Modified: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/BareMetal.cpp clang/lib/Driver/ToolChains/BareMetal.h clang/test/Driver/baremetal-multilib-custom-error.yaml clang/test/Driver/baremetal-multilib-exclusive-group.yaml clang/test/Driver/baremetal-multilib-group-error.yaml clang/test/Driver/baremetal-multilib-layered.yaml clang/test/Driver/baremetal-multilib.yaml clang/test/Driver/print-multi-selection-flags.c Removed: ################################################################################ diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 445e681313eba7..90f0c4f2df2130 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -5558,6 +5558,9 @@ def mthumb : Flag<["-"], "mthumb">, Group<m_Group>; def mtune_EQ : Joined<["-"], "mtune=">, Group<m_Group>, Visibility<[ClangOption, FlangOption]>, HelpText<"Only supported on AArch64, PowerPC, RISC-V, SPARC, SystemZ, and X86">; +def multi_lib_config : Joined<["-", "--"], "multi-lib-config=">, + HelpText<"Path to the YAML configuration file to be used for multilib selection">, + MetaVarName<"<file>">; def multi__module : Flag<["-"], "multi_module">; def multiply__defined__unused : Separate<["-"], "multiply_defined_unused">; def multiply__defined : Separate<["-"], "multiply_defined">; diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp index 8aed9ed6e18817..92b52e792478b5 100644 --- a/clang/lib/Driver/ToolChains/BareMetal.cpp +++ b/clang/lib/Driver/ToolChains/BareMetal.cpp @@ -97,9 +97,23 @@ static bool findRISCVMultilibs(const Driver &D, return false; } +static std::string computeBaseSysRoot(const Driver &D, bool IncludeTriple) { + if (!D.SysRoot.empty()) + return D.SysRoot; + + SmallString<128> SysRootDir(D.Dir); + llvm::sys::path::append(SysRootDir, "..", "lib", "clang-runtimes"); + + if (IncludeTriple) + llvm::sys::path::append(SysRootDir, D.getTargetTriple()); + + return std::string(SysRootDir); +} + BareMetal::BareMetal(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) - : ToolChain(D, Triple, Args) { + : ToolChain(D, Triple, Args), + SysRoot(computeBaseSysRoot(D, /*IncludeTriple=*/true)) { getProgramPaths().push_back(getDriver().Dir); findMultilibs(D, Triple, Args); @@ -194,26 +208,21 @@ static void findMultilibsFromYAML(const ToolChain &TC, const Driver &D, static constexpr llvm::StringLiteral MultilibFilename = "multilib.yaml"; -// Get the sysroot, before multilib takes effect. -static std::string computeBaseSysRoot(const Driver &D, - const llvm::Triple &Triple) { - if (!D.SysRoot.empty()) - return D.SysRoot; - - SmallString<128> SysRootDir(D.Dir); - llvm::sys::path::append(SysRootDir, "..", "lib", "clang-runtimes"); - - SmallString<128> MultilibPath(SysRootDir); - llvm::sys::path::append(MultilibPath, MultilibFilename); - - // New behaviour: if multilib.yaml is found then use clang-runtimes as the - // sysroot. - if (D.getVFS().exists(MultilibPath)) - return std::string(SysRootDir); - - // Otherwise fall back to the old behaviour of appending the target triple. - llvm::sys::path::append(SysRootDir, D.getTargetTriple()); - return std::string(SysRootDir); +static std::optional<llvm::SmallString<128>> +getMultilibConfigPath(const Driver &D, const llvm::Triple &Triple, + const ArgList &Args) { + llvm::SmallString<128> MultilibPath; + if (Arg *ConfigFileArg = Args.getLastArg(options::OPT_multi_lib_config)) { + MultilibPath = ConfigFileArg->getValue(); + if (!D.getVFS().exists(MultilibPath)) { + D.Diag(clang::diag::err_drv_no_such_file) << MultilibPath.str(); + return {}; + } + } else { + MultilibPath = computeBaseSysRoot(D, /*IncludeTriple=*/false); + llvm::sys::path::append(MultilibPath, MultilibFilename); + } + return MultilibPath; } void BareMetal::findMultilibs(const Driver &D, const llvm::Triple &Triple, @@ -221,10 +230,15 @@ void BareMetal::findMultilibs(const Driver &D, const llvm::Triple &Triple, DetectedMultilibs Result; // Look for a multilib.yaml before trying target-specific hardwired logic. // If it exists, always do what it specifies. - llvm::SmallString<128> MultilibPath(computeBaseSysRoot(D, Triple)); - llvm::sys::path::append(MultilibPath, MultilibFilename); - if (D.getVFS().exists(MultilibPath)) { - findMultilibsFromYAML(*this, D, MultilibPath, Args, Result); + std::optional<llvm::SmallString<128>> MultilibPath = + getMultilibConfigPath(D, Triple, Args); + if (!MultilibPath) + return; + if (D.getVFS().exists(*MultilibPath)) { + // If multilib.yaml is found, update sysroot so it doesn't use a target + // specific suffix + SysRoot = computeBaseSysRoot(D, /*IncludeTriple=*/false); + findMultilibsFromYAML(*this, D, *MultilibPath, Args, Result); SelectedMultilibs = Result.SelectedMultilibs; Multilibs = Result.Multilibs; } else if (isRISCVBareMetal(Triple)) { @@ -248,9 +262,7 @@ Tool *BareMetal::buildStaticLibTool() const { return new tools::baremetal::StaticLibTool(*this); } -std::string BareMetal::computeSysRoot() const { - return computeBaseSysRoot(getDriver(), getTriple()); -} +std::string BareMetal::computeSysRoot() const { return SysRoot; } BareMetal::OrderedMultilibs BareMetal::getOrderedMultilibs() const { // Get multilibs in reverse order because they're ordered most-specific last. diff --git a/clang/lib/Driver/ToolChains/BareMetal.h b/clang/lib/Driver/ToolChains/BareMetal.h index 67b5aa5998fc3d..b385c8cf76aab0 100644 --- a/clang/lib/Driver/ToolChains/BareMetal.h +++ b/clang/lib/Driver/ToolChains/BareMetal.h @@ -78,6 +78,8 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public ToolChain { using OrderedMultilibs = llvm::iterator_range<llvm::SmallVector<Multilib>::const_reverse_iterator>; OrderedMultilibs getOrderedMultilibs() const; + + std::string SysRoot; }; } // namespace toolchains diff --git a/clang/test/Driver/Inputs/multilib/empty.yaml b/clang/test/Driver/Inputs/multilib/empty.yaml new file mode 100644 index 00000000000000..82c476a13367cd --- /dev/null +++ b/clang/test/Driver/Inputs/multilib/empty.yaml @@ -0,0 +1,8 @@ + +MultilibVersion: 1.0 + +Variants: + +Mappings: + +... diff --git a/clang/test/Driver/baremetal-multilib-custom-error.yaml b/clang/test/Driver/baremetal-multilib-custom-error.yaml index c006bb4072ce2f..151eece9f69954 100644 --- a/clang/test/Driver/baremetal-multilib-custom-error.yaml +++ b/clang/test/Driver/baremetal-multilib-custom-error.yaml @@ -1,35 +1,28 @@ # REQUIRES: shell # UNSUPPORTED: system-windows -# RUN: rm -rf %t -# RUN: mkdir -p %t/bin -# RUN: mkdir -p %t/lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/lib -# RUN: touch %t/lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/lib/libclang_rt.builtins.a -# RUN: ln -s %clang %t/bin/clang -# RUN: ln -s %s %t/lib/clang-runtimes/multilib.yaml - -# RUN: %t/bin/clang -no-canonical-prefixes -print-multi-directory 2>&1 \ +# RUN: %clang --multi-lib-config=%s -no-canonical-prefixes -print-multi-directory 2>&1 \ # RUN: --target=thumbv8m.main-none-eabi -march=armv8.1m.main --sysroot= \ # RUN: | FileCheck --check-prefix=CHECK-PRINT-MULTI-DIRECTORY-NOMVE-SOFTFLOAT %s # CHECK-PRINT-MULTI-DIRECTORY-NOMVE-SOFTFLOAT: nomve-softfloat -# RUN: not %t/bin/clang -no-canonical-prefixes -print-multi-directory 2>&1 \ +# RUN: not %clang --multi-lib-config=%s -no-canonical-prefixes -print-multi-directory 2>&1 \ # RUN: --target=thumbv8m.main-none-eabi -march=armv8.1m.main+mve --sysroot= \ # RUN: | FileCheck --check-prefix=CHECK-ERROR %s # CHECK-ERROR: multilib configuration error: mve-softfloat is not supported -# RUN: %t/bin/clang -no-canonical-prefixes -print-multi-directory 2>&1 \ +# RUN: %clang --multi-lib-config=%s -no-canonical-prefixes -print-multi-directory 2>&1 \ # RUN: --target=thumbv8m.main-none-eabi -march=armv8.1m.main+mve -mfloat-abi=hard --sysroot= \ # RUN: | FileCheck --check-prefix=CHECK-PRINT-MULTI-DIRECTORY-MVE-HARDFLOAT %s # CHECK-PRINT-MULTI-DIRECTORY-MVE-HARDFLOAT: mve-hardfloat -# RUN: %t/bin/clang -no-canonical-prefixes -print-multi-lib 2>&1 \ +# RUN: %clang --multi-lib-config=%s -no-canonical-prefixes -print-multi-lib 2>&1 \ # RUN: --target=arm-none-eabi --sysroot= \ # RUN: | FileCheck --check-prefix=CHECK-PRINT-MULTI-LIB %s # CHECK-PRINT-MULTI-LIB: nomve-softfloat;@-target=thumbv8.1m.main-unknown-none-eabi # CHECK-PRINT-MULTI-LIB-NEXT: mve-hardfloat;@-target=thumbv8.1m.main-unknown-none-eabihf@march=thumbv8.1m.main+mve@mfloat-abi=hard -# RUN: %t/bin/clang -no-canonical-prefixes -print-multi-directory 2>&1 \ +# RUN: %clang --multi-lib-config=%s -no-canonical-prefixes -print-multi-directory 2>&1 \ # RUN: --target=arm-none-eabi --sysroot= \ # RUN: | FileCheck --check-prefix=CHECK-NO-MATCH-WARNING %s # CHECK-NO-MATCH-WARNING: clang: note: available multilibs are: diff --git a/clang/test/Driver/baremetal-multilib-exclusive-group.yaml b/clang/test/Driver/baremetal-multilib-exclusive-group.yaml index a98549efea4f0a..8f9e2900f92711 100644 --- a/clang/test/Driver/baremetal-multilib-exclusive-group.yaml +++ b/clang/test/Driver/baremetal-multilib-exclusive-group.yaml @@ -1,17 +1,9 @@ # UNSUPPORTED: system-windows -# RUN: rm -rf %t +# RUN: %clang --multi-lib-config=%s -no-canonical-prefixes -x c++ %s -### -o %t.out --target=thumbv7em-none-unknown-eabi --sysroot= 2>%t.err -# RUN: mkdir -p %t/baremetal_multilib/bin -# RUN: ln -s %clang %t/baremetal_multilib/bin/clang - -# RUN: mkdir -p %t/baremetal_multilib/lib/clang-runtimes -# RUN: ln -s %s %t/baremetal_multilib/lib/clang-runtimes/multilib.yaml - -# RUN: %t/baremetal_multilib/bin/clang -no-canonical-prefixes -x c++ %s -### -o %t.out --target=thumbv7em-none-unknown-eabi --sysroot= 2>%t.err - -# RUN: FileCheck -DSYSROOT=%t/baremetal_multilib %s < %t.err --check-prefix=POS -# RUN: FileCheck -DSYSROOT=%t/baremetal_multilib %s < %t.err --check-prefix=NEG +# RUN: FileCheck %s < %t.err --check-prefix=POS +# RUN: FileCheck %s < %t.err --check-prefix=NEG # Expected results: # @@ -25,14 +17,14 @@ # So we expect five of these seven directories to show up in the clang-cc1 # command line, but not testdir1_exclusive or testdir2_exclusive. -# POS-DAG: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/testdir1_non_exclusive/include/c++/v1" +# POS-DAG: "-internal-isystem" "[[SYSROOT:[^"]*]]/bin/../lib/clang-runtimes/testdir1_non_exclusive/include/c++/v1" # POS-DAG: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/testdir2_non_exclusive/include/c++/v1" # POS-DAG: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/testdir3_exclusive/include/c++/v1" # POS-DAG: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/testdir1_own_group/include/c++/v1" # POS-DAG: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/testdir2_own_group/include/c++/v1" -# NEG-NOT: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/testdir1_exclusive/include/c++/v1" -# NEG-NOT: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/testdir2_exclusive/include/c++/v1" +# NEG-NOT: "-internal-isystem" "{{[^"]*}}/bin/../lib/clang-runtimes/testdir1_exclusive/include/c++/v1" +# NEG-NOT: "-internal-isystem" "{{[^"]*}}/bin/../lib/clang-runtimes/testdir2_exclusive/include/c++/v1" --- MultilibVersion: 1.0 diff --git a/clang/test/Driver/baremetal-multilib-group-error.yaml b/clang/test/Driver/baremetal-multilib-group-error.yaml index 1e8f83fa50d244..b73e4bd21a43af 100644 --- a/clang/test/Driver/baremetal-multilib-group-error.yaml +++ b/clang/test/Driver/baremetal-multilib-group-error.yaml @@ -1,14 +1,6 @@ # UNSUPPORTED: system-windows -# RUN: rm -rf %t - -# RUN: mkdir -p %t/baremetal_multilib/bin -# RUN: ln -s %clang %t/baremetal_multilib/bin/clang - -# RUN: mkdir -p %t/baremetal_multilib/lib/clang-runtimes -# RUN: ln -s %s %t/baremetal_multilib/lib/clang-runtimes/multilib.yaml - -# RUN: %t/baremetal_multilib/bin/clang -no-canonical-prefixes -x c++ %s -### -o %t.out --target=thumbv7em-none-unknown-eabi --sysroot= 2>%t.err +# RUN: %clang --multi-lib-config=%s -no-canonical-prefixes -x c++ %s -### -o %t.out --target=thumbv7em-none-unknown-eabi --sysroot= 2>%t.err # RUN: FileCheck %s < %t.err --- diff --git a/clang/test/Driver/baremetal-multilib-layered.yaml b/clang/test/Driver/baremetal-multilib-layered.yaml index a525436d8122f5..6671d9d672f58e 100644 --- a/clang/test/Driver/baremetal-multilib-layered.yaml +++ b/clang/test/Driver/baremetal-multilib-layered.yaml @@ -9,24 +9,18 @@ # However -fno-exceptions is not yet supported for multilib selection # so we use a more contrived -mfloat-abi example instead. -# RUN: rm -rf %T/baremetal_multilib_layered -# RUN: mkdir -p %T/baremetal_multilib_layered/bin -# RUN: mkdir -p %T/baremetal_multilib_layered/lib/clang-runtimes -# RUN: ln -s %clang %T/baremetal_multilib_layered/bin/clang -# RUN: ln -s %s %T/baremetal_multilib_layered/lib/clang-runtimes/multilib.yaml - -# RUN: %T/baremetal_multilib_layered/bin/clang -no-canonical-prefixes -x c++ %s -### -o %t.out 2>&1 \ +# RUN: %clang --multi-lib-config=%s -no-canonical-prefixes -x c++ %s -### -o %t.out 2>&1 \ # RUN: --target=thumbv7m-none-eabi -mfloat-abi=softfp --sysroot= \ -# RUN: | FileCheck -DSYSROOT=%T/baremetal_multilib_layered %s +# RUN: | FileCheck %s # CHECK: "-cc1" "-triple" "thumbv7m-unknown-none-eabi" -# CHECK-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/softfp/include/c++/v1" +# CHECK-SAME: "-internal-isystem" "[[SYSROOT:[^"]*]]/bin/../lib/clang-runtimes/softfp/include/c++/v1" # CHECK-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/soft/include/c++/v1" # CHECK-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/softfp/include" # CHECK-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/soft/include" # CHECK-NEXT: "-L[[SYSROOT]]/bin/../lib/clang-runtimes/softfp/lib" # CHECK-SAME: "-L[[SYSROOT]]/bin/../lib/clang-runtimes/soft/lib" -# RUN: %T/baremetal_multilib_layered/bin/clang -no-canonical-prefixes -print-multi-directory 2>&1 \ +# RUN: %clang --multi-lib-config=%s -no-canonical-prefixes -print-multi-directory 2>&1 \ # RUN: --target=arm-none-eabi -mfloat-abi=softfp --sysroot= \ # RUN: | FileCheck --check-prefix=CHECK-PRINT-MULTI-DIRECTORY %s # CHECK-PRINT-MULTI-DIRECTORY: soft diff --git a/clang/test/Driver/baremetal-multilib.yaml b/clang/test/Driver/baremetal-multilib.yaml index 9ed83e4aec839c..b6bfd0ed3a94cb 100644 --- a/clang/test/Driver/baremetal-multilib.yaml +++ b/clang/test/Driver/baremetal-multilib.yaml @@ -1,18 +1,11 @@ # REQUIRES: shell # UNSUPPORTED: system-windows -# RUN: rm -rf %T/baremetal_multilib -# RUN: mkdir -p %T/baremetal_multilib/bin -# RUN: mkdir -p %T/baremetal_multilib/lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/lib -# RUN: touch %T/baremetal_multilib/lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/lib/libclang_rt.builtins.a -# RUN: ln -s %clang %T/baremetal_multilib/bin/clang -# RUN: ln -s %s %T/baremetal_multilib/lib/clang-runtimes/multilib.yaml - -# RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -x c++ %s -### -o %t.out 2>&1 \ +# RUN: %clang --multi-lib-config=%s -no-canonical-prefixes -x c++ %s -### -o %t.out 2>&1 \ # RUN: --target=thumbv8m.main-none-eabihf --sysroot= \ -# RUN: | FileCheck -DSYSROOT=%T/baremetal_multilib %s +# RUN: | FileCheck %s # CHECK: "-cc1" "-triple" "thumbv8m.main-unknown-none-eabihf" -# CHECK-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/include/c++/v1" +# CHECK-SAME: "-internal-isystem" "[[SYSROOT:[^"]*]]/bin/../lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/include/c++/v1" # CHECK-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/include" # CHECK-SAME: "-x" "c++" "{{.*}}baremetal-multilib.yaml" # CHECK-NEXT: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic" @@ -20,7 +13,7 @@ # CHECK-SAME: "-lc" "-lm" "{{[^"]*}}libclang_rt.builtins.a" # CHECK-SAME: "-o" "{{.*}}.tmp.out" -# RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -x c++ %s -### -o %t.out 2>&1 \ +# RUN: %clang --multi-lib-config=%s -no-canonical-prefixes -x c++ %s -### -o %t.out 2>&1 \ # RUN: --target=thumbv7em-none-eabi -mfpu=fpv4-sp-d16 --sysroot= \ # RUN: | FileCheck --check-prefix=CHECK-NO-MATCH %s # CHECK-NO-MATCH: warning: no multilib found matching flags: @@ -30,12 +23,12 @@ # CHECK-NO-MATCH: --target=thumbv7m-unknown-none-eabi -mfpu=none # CHECK-NO-MATCH: --target=thumbv7em-unknown-none-eabi -mfpu=none -# RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -print-multi-directory 2>&1 \ +# RUN: %clang --multi-lib-config=%s -no-canonical-prefixes -print-multi-directory 2>&1 \ # RUN: --target=thumbv8m.main-none-eabihf --sysroot= \ # RUN: | FileCheck --check-prefix=CHECK-PRINT-MULTI-DIRECTORY %s # CHECK-PRINT-MULTI-DIRECTORY: arm-none-eabi/thumb/v8-m.main/fp -# RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -print-multi-lib 2>&1 \ +# RUN: %clang --multi-lib-config=%s -no-canonical-prefixes -print-multi-lib 2>&1 \ # RUN: --target=arm-none-eabi --sysroot= \ # RUN: | FileCheck --check-prefix=CHECK-PRINT-MULTI-LIB %s # CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v6-m/nofp;@-target=thumbv6m-unknown-none-eabi@mfpu=none @@ -49,7 +42,7 @@ # CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v8.1-m.main/fp;@-target=thumbv8.1m.main-unknown-none-eabihf@mfpu=fp-armv8-fullfp16-sp-d16 # CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v8.1-m.main/nofp/mve;@-target=thumbv8.1m.main-unknown-none-eabihf@march=thumbv8.1m.main+mve@mfpu=none -# RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -x assembler -mexecute-only \ +# RUN: %clang --multi-lib-config=%s -no-canonical-prefixes -x assembler -mexecute-only \ # RUN: --target=arm-none-eabi --sysroot= %s -c -### 2>&1 \ # RUN: | FileCheck %s --check-prefix=CHECK-NO-EXECUTE-ONLY-ASM # CHECK-NO-EXECUTE-ONLY-ASM: warning: argument unused during compilation: '-mexecute-only' diff --git a/clang/test/Driver/print-multi-selection-flags.c b/clang/test/Driver/print-multi-selection-flags.c index b490ff13d30ebe..4bb62665ad8981 100644 --- a/clang/test/Driver/print-multi-selection-flags.c +++ b/clang/test/Driver/print-multi-selection-flags.c @@ -1,84 +1,84 @@ -// RUN: %clang -print-multi-flags-experimental --target=aarch64-linux -fc++-abi=itanium -fsanitize=address | FileCheck --check-prefix=CHECK-LINUX %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-linux -fc++-abi=itanium -fsanitize=address | FileCheck --check-prefix=CHECK-LINUX %s // CHECK-LINUX: --target=aarch64-unknown-linux -// RUN: %clang -print-multi-flags-experimental --target=aarch64-fuchsia -fsanitize=hwaddress | FileCheck --check-prefix=CHECK-FUCHSIA %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-fuchsia -fsanitize=hwaddress | FileCheck --check-prefix=CHECK-FUCHSIA %s // CHECK-FUCHSIA: --target=aarch64-unknown-fuchsia -// RUN: %clang -print-multi-flags-experimental --target=arm-none-eabi -mfloat-abi=soft -fno-exceptions -fno-rtti | FileCheck --check-prefix=CHECK-ARMV4T %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -mfloat-abi=soft -fno-exceptions -fno-rtti | FileCheck --check-prefix=CHECK-ARMV4T %s // CHECK-ARMV4T: --target=armv4t-unknown-none-eabi // CHECK-ARMV4T: -mfloat-abi=soft // CHECK-ARMV4T: -mfpu=none -// RUN: %clang -print-multi-flags-experimental --target=armv7em-none-eabi -mfloat-abi=softfp | FileCheck --check-prefix=CHECK-SOFTFP %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=armv7em-none-eabi -mfloat-abi=softfp | FileCheck --check-prefix=CHECK-SOFTFP %s // CHECK-SOFTFP: --target=thumbv7em-unknown-none-eabi // CHECK-SOFTFP: -mfloat-abi=softfp // CHECK-SOFTFP: -mfpu=fpv4-sp-d16 -// RUN: %clang -print-multi-flags-experimental --target=arm-none-eabihf -march=armv7em -mfpu=fpv5-d16 | FileCheck --check-prefix=CHECK-HARD %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabihf -march=armv7em -mfpu=fpv5-d16 | FileCheck --check-prefix=CHECK-HARD %s // CHECK-HARD: --target=thumbv7em-unknown-none-eabihf // CHECK-HARD: -mfloat-abi=hard // CHECK-HARD: -mfpu=fpv5-d16 -// RUN: %clang -print-multi-flags-experimental --target=aarch64-none-elf -mabi=aapcs | FileCheck --check-prefix=CHECK-ABI-AAPCS %s -// RUN: %clang -print-multi-flags-experimental --target=aarch64-none-elf -mabi=aapcs-soft | FileCheck --check-prefix=CHECK-ABI-AAPCS-SOFT %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -mabi=aapcs | FileCheck --check-prefix=CHECK-ABI-AAPCS %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -mabi=aapcs-soft | FileCheck --check-prefix=CHECK-ABI-AAPCS-SOFT %s // CHECK-ABI-AAPCS: -mabi=aapcs // CHECK-ABI-AAPCS-SOFT: -mabi=aapcs-soft -// RUN: %clang -print-multi-flags-experimental --target=arm-none-eabi -mfloat-abi=soft -march=armv8-m.main+nofp | FileCheck --check-prefix=CHECK-V8MMAIN-NOFP %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -mfloat-abi=soft -march=armv8-m.main+nofp | FileCheck --check-prefix=CHECK-V8MMAIN-NOFP %s // CHECK-V8MMAIN-NOFP: --target=thumbv8m.main-unknown-none-eabi // CHECK-V8MMAIN-NOFP: -mfloat-abi=soft // CHECK-V8MMAIN-NOFP: -mfpu=none -// RUN: %clang -print-multi-flags-experimental --target=arm-none-eabi -mfloat-abi=hard -march=armv8.1m.main+mve.fp | FileCheck --check-prefix=CHECK-MVE %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -mfloat-abi=hard -march=armv8.1m.main+mve.fp | FileCheck --check-prefix=CHECK-MVE %s // CHECK-MVE: --target=thumbv8.1m.main-unknown-none-eabihf // CHECK-MVE: -march=thumbv8.1m.main{{.*}}+mve{{.*}}+mve.fp{{.*}} // CHECK-MVE: -mfloat-abi=hard // CHECK-MVE: -mfpu=fp-armv8-fullfp16-sp-d16 -// RUN: %clang -print-multi-flags-experimental --target=arm-none-eabi -march=armv8.1m.main+mve+nofp | FileCheck --check-prefix=CHECK-MVENOFP %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -march=armv8.1m.main+mve+nofp | FileCheck --check-prefix=CHECK-MVENOFP %s // CHECK-MVENOFP: -march=thumbv8.1m.main{{.*}}+mve{{.*}} // CHECK-MVENOFP-NOT: -march=thumbv8.1m.main{{.*}}+mve.fp{{.*}} // CHECK-MVENOFP: -mfpu=none -// RUN: %clang -print-multi-flags-experimental --target=arm-none-eabihf -march=armv8.1m.main+fp.dp | FileCheck --check-prefix=CHECK-V8_1_FP_DP %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabihf -march=armv8.1m.main+fp.dp | FileCheck --check-prefix=CHECK-V8_1_FP_DP %s // CHECK-V8_1_FP_DP: -march=thumbv8.1m.main{{.*}} // CHECK-V8_1_FP_DP: -mfloat-abi=hard // CHECK-V8_1_FP_DP: -mfpu=fp-armv8-fullfp16-d16 -// RUN: %clang -print-multi-flags-experimental --target=arm-none-eabihf -march=armv8.1m.main+nofp+fp+nofp.dp | FileCheck --check-prefix=CHECK-V8_1_NO_FP_DP %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabihf -march=armv8.1m.main+nofp+fp+nofp.dp | FileCheck --check-prefix=CHECK-V8_1_NO_FP_DP %s // CHECK-V8_1_NO_FP_DP: -march=thumbv8.1m.main{{.*}} // CHECK-V8_1_NO_FP_DP: -mfloat-abi=hard // CHECK-V8_1_NO_FP_DP: -mfpu=fp-armv8-fullfp16-sp-d16 -// RUN: %clang -print-multi-flags-experimental --target=arm-none-eabihf -mcpu=cortex-m85+nofp.dp | FileCheck --check-prefix=CHECK-M85_NO_FP_DP %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabihf -mcpu=cortex-m85+nofp.dp | FileCheck --check-prefix=CHECK-M85_NO_FP_DP %s // CHECK-M85_NO_FP_DP: -march=thumbv8.1m.main{{.*}} // CHECK-M85_NO_FP_DP: -mfloat-abi=hard // CHECK-M85_NO_FP_DP: -mfpu=fp-armv8-fullfp16-sp-d16 -// RUN: %clang -print-multi-flags-experimental --target=aarch64-none-elf -march=armv8-a+lse | FileCheck --check-prefix=CHECK-LSE %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -march=armv8-a+lse | FileCheck --check-prefix=CHECK-LSE %s // CHECK-LSE: --target=aarch64-unknown-none-elf // CHECK-LSE: -march=armv8-a{{.*}}+lse{{.*}} -// RUN: %clang -print-multi-flags-experimental --target=aarch64-none-elf -march=armv8.5-a+sve+sve2 | FileCheck --check-prefix=CHECK-SVE2 %s -// RUN: %clang -print-multi-flags-experimental --target=aarch64-none-elf -march=armv9-a | FileCheck --check-prefix=CHECK-SVE2 %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -march=armv8.5-a+sve+sve2 | FileCheck --check-prefix=CHECK-SVE2 %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -march=armv9-a | FileCheck --check-prefix=CHECK-SVE2 %s // CHECK-SVE2: --target=aarch64-unknown-none-elf // CHECK-SVE2: -march=armv{{.*}}-a{{.*}}+simd{{.*}}+sve{{.*}}+sve2{{.*}} -// RUN: %clang -print-multi-flags-experimental --target=arm-none-eabi -mbranch-protection=standard | FileCheck --check-prefix=CHECK-BRANCH-PROTECTION %s -// RUN: %clang -print-multi-flags-experimental --target=aarch64-none-elf -mbranch-protection=standard | FileCheck --check-prefix=CHECK-BRANCH-PROTECTION %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -mbranch-protection=standard | FileCheck --check-prefix=CHECK-BRANCH-PROTECTION %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -mbranch-protection=standard | FileCheck --check-prefix=CHECK-BRANCH-PROTECTION %s // CHECK-BRANCH-PROTECTION: -mbranch-protection=standard -// RUN: %clang -print-multi-flags-experimental --target=riscv32-none-elf -march=rv32g | FileCheck --check-prefix=CHECK-RV32 %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=riscv32-none-elf -march=rv32g | FileCheck --check-prefix=CHECK-RV32 %s // CHECK-RV32: --target=riscv32-unknown-none-elf // CHECK-RV32: -mabi=ilp32d // CHECK-RV32: -march=rv32i{{[0-9]+p[0-9]+}}_m{{[0-9]+p[0-9]+}}_a{{[0-9]+p[0-9]+}}_f{{[0-9]+p[0-9]+}}_d{{[0-9]+p[0-9]+}}_zicsr{{[0-9]+p[0-9]+}}_zifencei{{[0-9]+p[0-9]+}}_zmmul{{[0-9]+p[0-9]+}} -// RUN: %clang -print-multi-flags-experimental --target=riscv64-none-elf -march=rv64g | FileCheck --check-prefix=CHECK-RV64 %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=riscv64-none-elf -march=rv64g | FileCheck --check-prefix=CHECK-RV64 %s // CHECK-RV64: --target=riscv64-unknown-none-elf // CHECK-RV64: -mabi=lp64d // CHECK-RV64: -march=rv64i{{[0-9]+p[0-9]+}}_m{{[0-9]+p[0-9]+}}_a{{[0-9]+p[0-9]+}}_f{{[0-9]+p[0-9]+}}_d{{[0-9]+p[0-9]+}}_zicsr{{[0-9]+p[0-9]+}}_zifencei{{[0-9]+p[0-9]+}}_zmmul{{[0-9]+p[0-9]+}} -// RUN: %clang -print-multi-flags-experimental --target=riscv32-none-elf -march=rv32e_zicsr_c | FileCheck --check-prefix=CHECK-RV32E-ORDER %s +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=riscv32-none-elf -march=rv32e_zicsr_c | FileCheck --check-prefix=CHECK-RV32E-ORDER %s // CHECK-RV32E-ORDER: --target=riscv32-unknown-none-elf // CHECK-RV32E-ORDER: -mabi=ilp32e // CHECK-RV32E-ORDER: -march=rv32e{{[0-9]+p[0-9]+}}_c{{[0-9]+p[0-9]+}}_zicsr{{[0-9]+p[0-9]+}} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits