llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.34k stars 12.13k forks source link

`TestCases/Darwin/dead-strip.c` fails #29115

Open zmodem opened 8 years ago

zmodem commented 8 years ago
Bugzilla Link 28743
Version trunk
OS Linux
CC @rgov

Extended Description

These two tests always fail on my Mac, both on trunk and 3.9.

They are the only two tests failing when testing the 3.9 release.

FAIL: AddressSanitizer-i386-darwin :: TestCases/Darwin/dead-strip.c (2185 of 35004)
******************** TEST 'AddressSanitizer-i386-darwin :: TestCases/Darwin/dead-strip.c' FAILED ********************
Script:
--
/work/release-test/branches_release_39/Phase3/Release/llvmCore-test-branches_release_39.obj/./bin/clang -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -arch i386 -mllvm -asan-globals-live-support -Xlink
er -dead_strip -o /work/release-test/branches_release_39/Phase3/Release/llvmCore-test-branches_release_39.obj/projects/compiler-rt/test/asan/I386DarwinConfig/TestCases/Darwin/Output/dead-strip.c.tmp /work/release-test/branches_release_39/llvm.src/projects/compiler-rt/test/a
san/TestCases/Darwin/dead-strip.c
llvm-nm -format=posix /work/release-test/branches_release_39/Phase3/Release/llvmCore-test-branches_release_39.obj/projects/compiler-rt/test/asan/I386DarwinConfig/TestCases/Darwin/Output/dead-strip.c.tmp | FileCheck --check-prefix NM-CHECK /work/release-test/branches_release
_39/llvm.src/projects/compiler-rt/test/asan/TestCases/Darwin/dead-strip.c
not  /work/release-test/branches_release_39/Phase3/Release/llvmCore-test-branches_release_39.obj/projects/compiler-rt/test/asan/I386DarwinConfig/TestCases/Darwin/Output/dead-strip.c.tmp 2>&1 | FileCheck --check-prefix ASAN-CHECK /work/release-test/branches_release_39/llvm.s
rc/projects/compiler-rt/test/asan/TestCases/Darwin/dead-strip.c
--
Exit Code: 1

Command Output (stderr):
--
<stdin>:11:1: error: NM-CHECK-NOT: string occurred!
_dead S 20e0 0
^
/work/release-test/branches_release_39/llvm.src/projects/compiler-rt/test/asan/TestCases/Darwin/dead-strip.c:16:18: note: NM-CHECK-NOT: pattern specified here
// NM-CHECK-NOT: {{^_dead }}
                 ^

--

********************
Testing: 0 .
FAIL: AddressSanitizer-x86_64-darwin :: TestCases/Darwin/dead-strip.c (2555 of 35004)
******************** TEST 'AddressSanitizer-x86_64-darwin :: TestCases/Darwin/dead-strip.c' FAILED ********************
Script:
--
/work/release-test/branches_release_39/Phase3/Release/llvmCore-test-branches_release_39.obj/./bin/clang -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -arch x86_64 -mllvm -asan-globals-live-support -Xli
nker -dead_strip -o /work/release-test/branches_release_39/Phase3/Release/llvmCore-test-branches_release_39.obj/projects/compiler-rt/test/asan/X86_64DarwinConfig/TestCases/Darwin/Output/dead-strip.c.tmp /work/release-test/branches_release_39/llvm.src/projects/compiler-rt/te
st/asan/TestCases/Darwin/dead-strip.c
llvm-nm -format=posix /work/release-test/branches_release_39/Phase3/Release/llvmCore-test-branches_release_39.obj/projects/compiler-rt/test/asan/X86_64DarwinConfig/TestCases/Darwin/Output/dead-strip.c.tmp | FileCheck --check-prefix NM-CHECK /work/release-test/branches_relea
se_39/llvm.src/projects/compiler-rt/test/asan/TestCases/Darwin/dead-strip.c
not  /work/release-test/branches_release_39/Phase3/Release/llvmCore-test-branches_release_39.obj/projects/compiler-rt/test/asan/X86_64DarwinConfig/TestCases/Darwin/Output/dead-strip.c.tmp 2>&1 | FileCheck --check-prefix ASAN-CHECK /work/release-test/branches_release_39/llvm
.src/projects/compiler-rt/test/asan/TestCases/Darwin/dead-strip.c
--
Exit Code: 1

Command Output (stderr):
--
<stdin>:11:1: error: NM-CHECK-NOT: string occurred!
_dead S 100001140 0
^
/work/release-test/branches_release_39/llvm.src/projects/compiler-rt/test/asan/TestCases/Darwin/dead-strip.c:16:18: note: NM-CHECK-NOT: pattern specified here
// NM-CHECK-NOT: {{^_dead }}
                 ^

--
$ sw_vers -productVersion
10.11.5
rgov commented 8 years ago

You're right, osx-ld64-live_support (which should maybe be renamed to macos-ld64-live_support) checks the system version instead of checking the linker version, which could be parsed out of ld -v. I'll try to address this.

Note that AddressSanitizerModule::ShouldUseMachOGlobalsSection doesn't quite do it correctly either; it bases the decision off of the target OS version, whereas it should use the linker version. However I don't know of a performant way to ask the linker whether it supports the feature. This causes false negatives and we end up falling back when we don't need to (when targeting an earlier OS).

zmodem commented 8 years ago

I have removed the test from 3.9 in r278427 to unblock 3.9.

zmodem commented 8 years ago

I think this is about the SDK versus OS version. The dead-strip.c test has a

// REQUIRES: osx-ld64-live_support

line, which is gated on sw_vers -productVersion being >= 10.11.

But on my machine, lit runs the tests with:

lit.py: util.py:254: note: using SDKROOT: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk'

With that in the environment, Clang invokes cc1 with:

"-macosx_version_min" "10.10.0"

Which in turn means lib/Transforms/Instrumentation/AddressSanitizer.cpp's AddressSanitizerModule::ShouldUseMachOGlobalsSection() will return false.