llvm-capstone/clang/test/Driver/fembed-bitcode.c
Fangrui Song 2632ebb551 [Driver] Render target options (e.g. -fuse-init-array) for -fembed-bitcode
Modern ELF platforms use -fuse-init-array to emit .init_array instead of
.ctors .  ld.bfd and gold --ctors-in-init-array merge .init_array and
.ctors into .init_array but lld doesn't do that.

If crtbegin*.o crtend*.o don't provide .ctors/.dtors, such .ctors in
user object files can lead to crash (see PR42002. The first and the last
elements in .ctors/.dtors are ignored - they are traditionally provided
by crtbegin*.o crtend*.o).

Call addClangTargetOptions() to ensure -fuse-init-array is rendered on
modern ELF platforms. On Hexagon, this renders -target-feature
+reserved-r19 for -ffixed-r19.

Reviewed By: compnerd

Differential Revision: https://reviews.llvm.org/D62509

llvm-svn: 362052
2019-05-30 02:30:04 +00:00

37 lines
1.2 KiB
C

// RUN: %clang -target x86_64-apple-macosx -fembed-bitcode=all -c %s -o /dev/null -### 2>&1 \
// RUN: | FileCheck -check-prefix CHECK-X64 %s
// CHECK-X64: "-cc1"
// CHECK-X64: "-cc1"
// CHECK-X64-NOT: "-fdebug-compilation-dir"
// RUN: %clang -target armv7-apple-ios -fembed-bitcode=all -c %s -o /dev/null -### 2>&1 \
// RUN: | FileCheck -check-prefix CHECK-ARM %s
// CHECK-ARM: "-cc1"
// CHECK-ARM: "-cc1"
// CHECK-ARM: "-target-abi"
// CHECK-ARM: "apcs-gnu"
// CHECK-ARM-NOT: "-fdebug-compilation-dir"
// RUN: %clang -target arm64-apple-ios -fembed-bitcode=all -c %s -o /dev/null -### 2>&1 \
// RUN: | FileCheck -check-prefix CHECK-AARCH64 %s
// CHECK-AARCH64: "-cc1"
// CHECK-AARCH64: "-cc1"
// CHECK-AARCH64: "-target-abi"
// CHECK-AARCH64: "darwinpcs"
// CHECK-AARCH64-NOT: "-fdebug-compilation-dir"
// RUN: %clang -target x86_64-pc-freebsd12 -fembed-bitcode=all -c %s -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-INITARRAY %s
// CHECK-INITARRAY: "-fuse-init-array"
// RUN: %clang -target hexagon-unknown-elf -ffixed-r19 -fembed-bitcode=all -c %s -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-HEXAGON %s
// CHECK-HEXAGON: "-target-feature"
// CHECK-HEXAGON: "+reserved-r19"