简体   繁体   中英

How can I figure out what “target” an object file/module is compiled for on Mac OS Lion (e.g. “x86_64-apple-darwin11.0”)?

I'm trying to compile some code for OS X Lion and I'm running into problems with linking the object files and libraries. I get this error:

WARNING: Linking two modules of different target triples: 'x86_64-apple-darwin11.0' and 'x86_64-apple-darwin10'

Is there a command line tool/command that I can run to see what the target of the object files or libraries is? Then I can go back and debug the compiling to process to make sure everyone is targeting the same build.

Thanks! -Don

For llvm bitcode modules you can disassemble them using llvm-dis and look at the module there:

[yendi:~] echristo% llvm-dis foo.bc -o - | grep "target triple"
target triple = "x86_64-apple-macosx10.7.0"

Not complete information, but in general to get the architecture you'll want to use 'file':

For an individual .o file:

[yendi:~] echristo% file foo.o
foo.o: Mach-O 64-bit object x86_64

or if you're creating a bitcode file with -O4:

[yendi:~] echristo% /Volumes/Data/builds/build-llvm/Debug+Asserts/bin/clang++ foo.cc -c -emit-llvm -o foo.bc -O4
[yendi:~] echristo% file foo.bc
foo.bc: LLVM bit-code object x86_64

which won't get you the full triple, but will get you file information.

My guess is that you have some old object files sitting around or are pass -mmacosx-version-min=10.6 on some files and not on others.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM