Created
February 26, 2015 22:05
-
-
Save mystor/554d675276e768449b8f to your computer and use it in GitHub Desktop.
Strange clang behaviour
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% gcc --version | |
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 | |
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn) | |
Target: x86_64-apple-darwin14.0.0 | |
Thread model: posix | |
% gcc test.c | |
Undefined symbols for architecture x86_64: | |
"_foo", referenced from: | |
_main in test-696342.o | |
ld: symbol(s) not found for architecture x86_64 | |
clang: error: linker command failed with exit code 1 (use -v to see invocation) | |
% gcc -O2 test.c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ModuleID = '/var/folders/28/3w_1bq9s3p96j2xy5xmbvxjr0000gn/T/tmpppDdd6/code.c' | |
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" | |
target triple = "x86_64-apple-macosx10.10.0" | |
; Function Attrs: nounwind ssp uwtable | |
define i32 @main() #0 { | |
%1 = alloca i32, align 4 | |
store i32 0, i32* %1 | |
%2 = call i32 (...)* @foo() | |
ret i32 %2 | |
} | |
declare i32 @foo(...) #1 | |
attributes #0 = { nounwind ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } | |
attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } | |
!llvm.ident = !{!0} | |
!0 = metadata !{metadata !"Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ModuleID = '/var/folders/28/3w_1bq9s3p96j2xy5xmbvxjr0000gn/T/tmpEzyLyo/code.c' | |
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" | |
target triple = "x86_64-apple-macosx10.10.0" | |
; Function Attrs: nounwind readnone ssp uwtable | |
define i32 @main() #0 { | |
ret i32 5 | |
} | |
attributes #0 = { nounwind readnone ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } | |
!llvm.ident = !{!0} | |
!0 = metadata !{metadata !"Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline int foo() { | |
return 5; | |
} | |
int main() { | |
return foo(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment