Author: Nico Weber
Date: 2020-11-23T13:32:29-05:00
New Revision: 47eb5ce19ab10bcfe00af04e6a6e39613e2cb3c9

URL: 
https://github.com/llvm/llvm-project/commit/47eb5ce19ab10bcfe00af04e6a6e39613e2cb3c9
DIFF: 
https://github.com/llvm/llvm-project/commit/47eb5ce19ab10bcfe00af04e6a6e39613e2cb3c9.diff

LOG: [mac/arm] fix clang/test/Driver/darwin-ld-dedup.c

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.

Added: 
    clang/test/Driver/Inputs/empty-x86_64-apple-darwin.yaml

Modified: 
    clang/test/CMakeLists.txt
    clang/test/Driver/darwin-ld-dedup.c
    clang/test/lit.cfg.py
    llvm/utils/gn/secondary/clang/test/BUILD.gn

Removed: 
    


################################################################################
diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 1eb434e192db..4e9a1840fec3 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -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
index 000000000000..c4561050b8b6
--- /dev/null
+++ b/clang/test/Driver/Inputs/empty-x86_64-apple-darwin.yaml
@@ -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
+...

diff  --git a/clang/test/Driver/darwin-ld-dedup.c 
b/clang/test/Driver/darwin-ld-dedup.c
index a06ca7bebe57..1d866f40291a 100644
--- a/clang/test/Driver/darwin-ld-dedup.c
+++ b/clang/test/Driver/darwin-ld-dedup.c
@@ -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 \

diff  --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 1a6e73ed9783..863ab444fb02 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -64,7 +64,7 @@
 
 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'),
 ]

diff  --git a/llvm/utils/gn/secondary/clang/test/BUILD.gn 
b/llvm/utils/gn/secondary/clang/test/BUILD.gn
index 9219d2d7bfad..8f436ac10586 100644
--- a/llvm/utils/gn/secondary/clang/test/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/test/BUILD.gn
@@ -168,6 +168,7 @@ group("test") {
     "//llvm/utils/count",
     "//llvm/utils/llvm-lit",
     "//llvm/utils/not",
+    "//llvm/tools/yaml2obj",
   ]
   if (clang_enable_arcmt) {
     deps += [


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to