[mac/arm] fix clang/test/Driver/darwin-ld-dedup.c
authorNico Weber <thakis@chromium.org>
Mon, 23 Nov 2020 18:29:36 +0000 (13:29 -0500)
committerNico Weber <thakis@chromium.org>
Mon, 23 Nov 2020 18:32:29 +0000 (13:32 -0500)
The test needs an object file, which it currenty gets with
`-target x86_64-apple-darwin10`.  Rather than adding `REQUIRES: X86`, create
the object file via yaml2obj. This way, the test runs and passes even if the
host arch isn't x86 and only the host arch is built.

Part of PR46644.

clang/test/CMakeLists.txt
clang/test/Driver/Inputs/empty-x86_64-apple-darwin.yaml [new file with mode: 0644]
clang/test/Driver/darwin-ld-dedup.c
clang/test/lit.cfg.py
llvm/utils/gn/secondary/clang/test/BUILD.gn

index 1eb434e192db68bc6cab6798d9fa72a5dddb7c5a..4e9a1840fec3c16e2324442b020810f58bf46395 100644 (file)
@@ -124,6 +124,7 @@ if( NOT CLANG_BUILT_STANDALONE )
     llvm-readobj
     llvm-symbolizer
     opt
+    yaml2obj
     )
 
   if(TARGET llvm-lto)
diff --git a/clang/test/Driver/Inputs/empty-x86_64-apple-darwin.yaml b/clang/test/Driver/Inputs/empty-x86_64-apple-darwin.yaml
new file mode 100644 (file)
index 0000000..c456105
--- /dev/null
@@ -0,0 +1,44 @@
+# Created by `clang -target x86_64-apple-darwin10 -c -x c /dev/null -o - | obj2yaml`.
+--- !mach-o
+FileHeader:
+  magic:           0xFEEDFACF
+  cputype:         0x1000007
+  cpusubtype:      0x3
+  filetype:        0x1
+  ncmds:           2
+  sizeofcmds:      176
+  flags:           0x2000
+  reserved:        0x0
+LoadCommands:
+  - cmd:             LC_SEGMENT_64
+    cmdsize:         152
+    segname:         ''
+    vmaddr:          0
+    vmsize:          0
+    fileoff:         208
+    filesize:        0
+    maxprot:         7
+    initprot:        7
+    nsects:          1
+    flags:           0
+    Sections:
+      - sectname:        __text
+        segname:         __TEXT
+        addr:            0x0
+        size:            0
+        offset:          0xD0
+        align:           0
+        reloff:          0x0
+        nreloc:          0
+        flags:           0x80000000
+        reserved1:       0x0
+        reserved2:       0x0
+        reserved3:       0x0
+        content:         ''
+  - cmd:             LC_BUILD_VERSION
+    cmdsize:         24
+    platform:        1
+    minos:           720896
+    sdk:             720896
+    ntools:          0
+...
index a06ca7bebe57a7167e27fc8e562cf56b5b39ca09..1d866f40291abf76cf1dfd89b0400588b497778c 100644 (file)
@@ -29,7 +29,7 @@
 // Do *not* add -no_deduplicate when no -O option is specified and this is just a link
 // (since we can't imply -O0)
 // RUN: rm -f %t.o %t.bin
-// RUN: %clang -target x86_64-apple-darwin10 -c -o %t.o %s
+// RUN: yaml2obj %S/Inputs/empty-x86_64-apple-darwin.yaml -o %t.o
 // RUN: %clang -target x86_64-apple-darwin10 %t.o -### -mlinker-version=262 \
 // RUN:   -o %t.bin 2>&1 | FileCheck -check-prefix=LINK_DEDUP %s
 // RUN: %clang -target x86_64-apple-darwin10 %t.o -### -mlinker-version=262 \
index 1a6e73ed97839b5fb501c069ed1e8dbfa96f03b8..863ab444fb023766fc27438c46ef99555fb0d31a 100644 (file)
@@ -64,7 +64,7 @@ tool_dirs = [config.clang_tools_dir, config.llvm_tools_dir]
 
 tools = [
     'apinotes-test', 'c-index-test', 'clang-diff', 'clang-format',
-    'clang-tblgen', 'opt', 'llvm-ifs',
+    'clang-tblgen', 'opt', 'llvm-ifs', 'yaml2obj',
     ToolSubst('%clang_extdef_map', command=FindTool(
         'clang-extdef-mapping'), unresolved='ignore'),
 ]
index 9219d2d7bfadc45fbef086a7e0d8f684ee210d1a..8f436ac10586400f7559f29340b90df87346a6e2 100644 (file)
@@ -168,6 +168,7 @@ group("test") {
     "//llvm/utils/count",
     "//llvm/utils/llvm-lit",
     "//llvm/utils/not",
+    "//llvm/tools/yaml2obj",
   ]
   if (clang_enable_arcmt) {
     deps += [