LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 32741 - Darwin -fsanitize=cfi -flto=thin causes raw bitcode to be emitted, instead of Mach-O-wrapped bitcode
Summary: Darwin -fsanitize=cfi -flto=thin causes raw bitcode to be emitted, instead of...
Status: NEW
Alias: None
Product: new-bugs
Classification: Unclassified
Component: new bugs (show other bugs)
Version: unspecified
Hardware: PC All
: P enhancement
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-21 17:16 PDT by Ahmed Bougacha
Modified: 2017-04-21 17:27 PDT (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ahmed Bougacha 2017-04-21 17:16:49 PDT
r301016 enabled CFI tests using ThinLTO on Darwin, but those are failing:

ld: warning: ignoring file /var/folders/09/r4vw4v8n5kb67jl66zvlbljw0000gn/T/lit_tmp_j2NEGY/nvcall-1477f4.o, file was built for unsupported file format ( 0x42 0x43 0xC0 0xDE 0x35 0x14 0x00 0x00 0x05 0x00 0x00 0x00 0x62 0x0C 0x30 0x24 ) which is not the architecture being linked (x86_64): /var/folders/09/r4vw4v8n5kb67jl66zvlbljw0000gn/T/lit_tmp_j2NEGY/nvcall-1477f4.o
Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64

http://green.lab.llvm.org/green/job/clang-stage1-configure-RA_check/30480/consoleFull#-121919748349ba4694-19c4-4d7e-bec5-911270d8a58c


It seems that -fsanitize=cfi somehow causes -flto=thin to emit bitcode instead of mach-o:

 $ ./bin/clang -flto=thin -fvisibility=hidden -fsanitize=cfi /tmp/t.cpp -c && file t.o
t.o: LLVM IR bitcode
 $ ./bin/clang -flto=thin -fvisibility=hidden /tmp/t.cpp -c && file t.o
t.o: LLVM bitcode, wrapper x86_64

And it seems that ld64 doesn't accept raw bitcode.
Comment 1 Peter Collingbourne 2017-04-21 17:26:09 PDT
This has no hope of working until ld64 is changed to use the resolution-based LTO API. Until then, we will need to change the clang driver to prevent the use of -flto=thin with -fsanitize=cfi (and -fwhole-program-vtables).
Comment 2 Peter Collingbourne 2017-04-21 17:27:14 PDT
...on Darwin.