| 1 | # REQUIRES: shell |
| 2 | # UNSUPPORTED: system-windows |
| 3 | |
| 4 | # RUN: rm -rf %T/baremetal_multilib |
| 5 | # RUN: mkdir -p %T/baremetal_multilib/bin |
| 6 | # RUN: mkdir -p %T/baremetal_multilib/lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/lib |
| 7 | # RUN: touch %T/baremetal_multilib/lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/lib/libclang_rt.builtins.a |
| 8 | # RUN: ln -s %clang %T/baremetal_multilib/bin/clang |
| 9 | # RUN: ln -s %s %T/baremetal_multilib/lib/clang-runtimes/multilib.yaml |
| 10 | |
| 11 | # RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -x c++ %s -### -o %t.out 2>&1 \ |
| 12 | # RUN: --target=thumbv8m.main-none-eabihf --sysroot= \ |
| 13 | # RUN: | FileCheck -DSYSROOT=%T/baremetal_multilib %s |
| 14 | # CHECK: "-cc1" "-triple" "thumbv8m.main-unknown-none-eabihf" |
| 15 | # CHECK-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/include/c++/v1" |
| 16 | # CHECK-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/include" |
| 17 | # CHECK-SAME: "-x" "c++" "{{.*}}baremetal-multilib.yaml" |
| 18 | # CHECK-NEXT: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic" |
| 19 | # CHECK-SAME: "-L[[SYSROOT]]/bin/../lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/lib" |
| 20 | # CHECK-SAME: "-lc" "-lm" "{{[^"]*}}libclang_rt.builtins.a" |
| 21 | # CHECK-SAME: "-o" "{{.*}}.tmp.out" |
| 22 | |
| 23 | # RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -x c++ %s -### -o %t.out 2>&1 \ |
| 24 | # RUN: --target=thumbv7em-none-eabi -mfpu=fpv4-sp-d16 --sysroot= \ |
| 25 | # RUN: | FileCheck --check-prefix=CHECK-NO-MATCH %s |
| 26 | # CHECK-NO-MATCH: warning: no multilib found matching flags: |
| 27 | # CHECK-NO-MATCH-SAME: --target=thumbv7em-unknown-none-eabi |
| 28 | # CHECK-NO-MATCH: note: available multilibs are: |
| 29 | # CHECK-NO-MATCH: --target=thumbv6m-unknown-none-eabi -mfpu=none |
| 30 | # CHECK-NO-MATCH: --target=thumbv7m-unknown-none-eabi -mfpu=none |
| 31 | # CHECK-NO-MATCH: --target=thumbv7em-unknown-none-eabi -mfpu=none |
| 32 | |
| 33 | # RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -print-multi-directory 2>&1 \ |
| 34 | # RUN: --target=thumbv8m.main-none-eabihf --sysroot= \ |
| 35 | # RUN: | FileCheck --check-prefix=CHECK-PRINT-MULTI-DIRECTORY %s |
| 36 | # CHECK-PRINT-MULTI-DIRECTORY: arm-none-eabi/thumb/v8-m.main/fp |
| 37 | |
| 38 | # RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -print-multi-lib 2>&1 \ |
| 39 | # RUN: --target=arm-none-eabi --sysroot= \ |
| 40 | # RUN: | FileCheck --check-prefix=CHECK-PRINT-MULTI-LIB %s |
| 41 | # CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v6-m/nofp;@-target=thumbv6m-unknown-none-eabi@mfpu=none |
| 42 | # CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v7-m/nofp;@-target=thumbv7m-unknown-none-eabi@mfpu=none |
| 43 | # CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v7e-m/nofp;@-target=thumbv7em-unknown-none-eabi@mfpu=none |
| 44 | # CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v8-m.main/nofp;@-target=thumbv8m.main-unknown-none-eabi@mfpu=none |
| 45 | # CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v8.1-m.main/nofp/nomve;@-target=thumbv8.1m.main-unknown-none-eabi@mfpu=none |
| 46 | # CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v7e-m/fpv4_sp_d16;@-target=thumbv7em-unknown-none-eabihf@mfpu=fpv4-sp-d16 |
| 47 | # CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v7e-m/fpv5_d16;@-target=thumbv7em-unknown-none-eabihf@mfpu=fpv5-d16 |
| 48 | # CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v8-m.main/fp;@-target=thumbv8m.main-unknown-none-eabihf@mfpu=fpv5-d16 |
| 49 | # 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 |
| 50 | # 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 |
| 51 | |
| 52 | # RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -x assembler -mexecute-only \ |
| 53 | # RUN: --target=arm-none-eabi --sysroot= %s -c -### 2>&1 \ |
| 54 | # RUN: | FileCheck %s --check-prefix=CHECK-NO-EXECUTE-ONLY-ASM |
| 55 | # CHECK-NO-EXECUTE-ONLY-ASM: warning: argument unused during compilation: '-mexecute-only' |
| 56 | |
| 57 | --- |
| 58 | # This file is in two parts: |
| 59 | # 1. A list of library variants. |
| 60 | # 2. A mapping from flags generated from command line arguments to further |
| 61 | # flags. |
| 62 | |
| 63 | # How does clang use this file? |
| 64 | # 1. If the ToolChain class for the architecture supports this form of |
| 65 | # multilib it then it loads the file if present in sysroot. |
| 66 | # 2. Generate flags from the user provided arguments. |
| 67 | # (Use `clang -print-multi-flags-experimental` to see which flags are |
| 68 | # generated). |
| 69 | # 3. Compare the arguments against each regular expression and store |
| 70 | # associated flags if there's a match. |
| 71 | # 4. Find the last library variant whose flags are a subset of the |
| 72 | # flags derived from the user provided arguments. |
| 73 | # 5. Use the directory for the library variant as the sysroot. |
| 74 | |
| 75 | # Clang will emit an error if this number is greater than its current multilib |
| 76 | # version or if its major version differs, but will accept lesser minor |
| 77 | # versions. |
| 78 | MultilibVersion: 1.0 |
| 79 | |
| 80 | # The first section of the file is the list of library variants. |
| 81 | # A library is considered compatible if the are a subset of the flags derived |
| 82 | # from the arguments provided by the user. |
| 83 | # If multiple libraries are deemed compatible then the one that appears |
| 84 | # last in the list wins. A ToolChain may instead opt to use more than one |
| 85 | # multilib, layered on top of each other. |
| 86 | |
| 87 | Variants: |
| 88 | - Dir: arm-none-eabi/arm/v4t |
| 89 | Flags: [--target=armv4t-unknown-none-eabi] |
| 90 | |
| 91 | - Dir: arm-none-eabi/thumb/v6-m/nofp |
| 92 | Flags: [--target=thumbv6m-unknown-none-eabi, -mfpu=none] |
| 93 | |
| 94 | - Dir: arm-none-eabi/thumb/v7-m/nofp |
| 95 | Flags: [--target=thumbv7m-unknown-none-eabi, -mfpu=none] |
| 96 | |
| 97 | - Dir: arm-none-eabi/thumb/v7e-m/nofp |
| 98 | Flags: [--target=thumbv7em-unknown-none-eabi, -mfpu=none] |
| 99 | |
| 100 | - Dir: arm-none-eabi/thumb/v8-m.main/nofp |
| 101 | Flags: [--target=thumbv8m.main-unknown-none-eabi, -mfpu=none] |
| 102 | |
| 103 | - Dir: arm-none-eabi/thumb/v8.1-m.main/nofp/nomve |
| 104 | Flags: [--target=thumbv8.1m.main-unknown-none-eabi, -mfpu=none] |
| 105 | |
| 106 | - Dir: arm-none-eabi/thumb/v7e-m/fpv4_sp_d16 |
| 107 | Flags: [--target=thumbv7em-unknown-none-eabihf, -mfpu=fpv4-sp-d16] |
| 108 | |
| 109 | - Dir: arm-none-eabi/thumb/v7e-m/fpv5_d16 |
| 110 | Flags: [--target=thumbv7em-unknown-none-eabihf, -mfpu=fpv5-d16] |
| 111 | |
| 112 | - Dir: arm-none-eabi/thumb/v8-m.main/fp |
| 113 | Flags: [--target=thumbv8m.main-unknown-none-eabihf, -mfpu=fpv5-d16] |
| 114 | |
| 115 | - Dir: arm-none-eabi/thumb/v8.1-m.main/fp |
| 116 | Flags: [--target=thumbv8.1m.main-unknown-none-eabihf, -mfpu=fp-armv8-fullfp16-sp-d16] |
| 117 | |
| 118 | - Dir: arm-none-eabi/thumb/v8.1-m.main/nofp/mve |
| 119 | Flags: [--target=thumbv8.1m.main-unknown-none-eabihf, -march=thumbv8.1m.main+mve, -mfpu=none] |
| 120 | |
| 121 | |
| 122 | # The second section of the file is a map from auto-detected flags |
| 123 | # to custom flags. The auto-detected flags can be printed out |
| 124 | # by running clang with `-print-multi-flags-experimental`. |
| 125 | # The regex must match a whole flag string. |
| 126 | # All flags in the "Flags" list will be added if an argument matches. |
| 127 | Mappings: |
| 128 | # For v8m.base (and potential later v8m baseline versions) use v6m |
| 129 | - Match: --target=thumbv8(\.[0-9]+)?m\.base-unknown-none-eabi |
| 130 | Flags: [--target=thumbv6m-unknown-none-eabi] |
| 131 | # Match versions after v8.1m.main. We assume that v8.2m (if/when it exists) will |
| 132 | # be backwards compatible with v8.1m. |
| 133 | # The alternative is to not recognise later versions, and require that |
| 134 | # this multilib spec is updated before it can be used with newer |
| 135 | # architecture versions. |
| 136 | - Match: --target=thumbv8\.[1-9]m\.main-unknown-none-eabi |
| 137 | Flags: [--target=thumbv8.1m.main-unknown-none-eabi] |
| 138 | - Match: --target=thumbv8\.[1-9]m\.main-unknown-none-eabihf |
| 139 | Flags: [--target=thumbv8.1m.main-unknown-none-eabihf] |
| 140 | |
| 141 | - Match: -march=thumbv8\.[1-9]m\.main.*\+mve($|\+).* |
| 142 | Flags: [-march=thumbv8.1m.main+mve] |
| 143 | |
| 144 | # Hierarchy among FPUs: fpvN-d16 is a superset of fpvN-sp-d16, and |
| 145 | # fpvN-d16 is a superset of fpv[N-1]-d16, for all N. |
| 146 | - Match: -mfpu=fpv5-d16 |
| 147 | Flags: |
| 148 | - -mfpu=fpv4-d16 |
| 149 | - -mfpu=fpv5-sp-d16 |
| 150 | - -mfpu=fpv4-sp-d16 |
| 151 | - Match: -mfpu=fpv5-sp-d16 |
| 152 | Flags: |
| 153 | - -mfpu=fpv4-sp-d16 |
| 154 | - Match: -mfpu=fpv4-d16 |
| 155 | Flags: |
| 156 | - -mfpu=fpv4-sp-d16 |
| 157 | |
| 158 | ... |