Comments (10)
off topic: I'm a bit confused about ./build_gcc -- does that produce the clang gcc frontend, or does it build a vanilla gcc that has nothing to do with clang?
from osxcross.
tools/get_dependencies.sh
does not cover GCC.
Quoting the README:
But before you do this, make sure you have got the GCC build depedencies installed on your system.
On debian like systems you can run:
[sudo] apt-get install gcc g++ zlib1g-dev libmpc-dev libmpfr-dev libgmp-dev
to install them.
Please post the output of o32-gcc test.c -v
.
off topic: I'm a bit confused about ./build_gcc -- does that produce the clang gcc frontend, or does it build a vanilla gcc that has nothing to do with clang?
./build_gcc.sh
has nothing to do with clang, clang is a cross compiler by default and works out of the box.
from osxcross.
From target/bin
I typed ./o32-gcc ../../oclang/test.c -v
Here's the output:
Using built-in specs.
COLLECT_GCC=i386-apple-darwin11-gcc
COLLECT_LTO_WRAPPER=/home/cosmin/osxcross/target/bin/../libexec/gcc/x86_64-apple-darwin11/5.2.0/lto-wrapper
Target: x86_64-apple-darwin11
Configured with: ../configure --target=x86_64-apple-darwin11 --with-sysroot=/home/cosmin/osxcross/target/bin/../SDK/MacOSX10.7.sdk --disable-nls --enable-languages=c,c++,objc,obj-c++ --without-headers --enable-multilib --with-multilib-list=m32,m64 --enable-lto --enable-checking=release --disable-libstdcxx-pch --prefix=/home/cosmin/osxcross/target/bin/.. --with-system-zlib --with-ld=/home/cosmin/osxcross/target/bin/../bin/x86_64-apple-darwin11-ld --with-as=/home/cosmin/osxcross/target/bin/../bin/x86_64-apple-darwin11-as
Thread model: posix
gcc version 5.2.0 (GCC)
COLLECT_GCC_OPTIONS='-static-libgcc' '-static-libstdc++' '-isystem' '/home/cosmin/osxcross/target/bin/../SDK/MacOSX10.7.sdk' '-mmacosx-version-min=10.5.0' '-m32' '-v' '-mtune=core2'
/home/cosmin/osxcross/target/bin/../libexec/gcc/x86_64-apple-darwin11/5.2.0/cc1 -quiet -v -imultilib i386 -iprefix /home/cosmin/osxcross/target/bin/../lib/gcc/x86_64-apple-darwin11/5.2.0/ -isysroot /home/cosmin/osxcross/target/bin/../SDK/MacOSX10.7.sdk -D__DYNAMIC__ -isystem /home/cosmin/osxcross/target/bin/../SDK/MacOSX10.7.sdk ../../oclang/test.c -fPIC -quiet -dumpbase test.c -mmacosx-version-min=10.5.0 -m32 -mtune=core2 -auxbase test -version -o /tmp/ccRz0P7k.s
GNU C11 (GCC) version 5.2.0 (x86_64-apple-darwin11)
compiled by GNU C version 4.2.1 Compatible Ubuntu Clang 3.4 (tags/RELEASE_34/final), GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=80 --param ggc-min-heapsize=94875
ignoring nonexistent directory ""
ignoring nonexistent directory "/home/cosmin/osxcross/target/bin/../SDK/MacOSX10.7.sdk/usr/local/include"
ignoring nonexistent directory ""
ignoring nonexistent directory ""
ignoring nonexistent directory "/home/cosmin/osxcross/target/bin/../SDK/MacOSX10.7.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/home/cosmin/osxcross/target/bin/../SDK/MacOSX10.7.sdk
/home/cosmin/osxcross/target/bin/../lib/gcc/x86_64-apple-darwin11/5.2.0/include
/home/cosmin/osxcross/target/bin/../lib/gcc/x86_64-apple-darwin11/5.2.0/include-fixed
/home/cosmin/osxcross/target/bin/../lib/gcc/x86_64-apple-darwin11/5.2.0/../../../../x86_64-apple-darwin11/include
/home/cosmin/osxcross/target/bin/../SDK/MacOSX10.7.sdk/usr/include
/home/cosmin/osxcross/target/bin/../SDK/MacOSX10.7.sdk/System/Library/Frameworks
End of search list.
GNU C11 (GCC) version 5.2.0 (x86_64-apple-darwin11)
compiled by GNU C version 4.2.1 Compatible Ubuntu Clang 3.4 (tags/RELEASE_34/final), GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=80 --param ggc-min-heapsize=94875
Compiler executable checksum: 37b8d6aec3ee9e5ced000ec1b7d4de3b
COLLECT_GCC_OPTIONS='-static-libgcc' '-static-libstdc++' '-isystem' '/home/cosmin/osxcross/target/bin/../SDK/MacOSX10.7.sdk' '-mmacosx-version-min=10.5.0' '-m32' '-v' '-mtune=core2'
/home/cosmin/osxcross/target/bin/../bin/x86_64-apple-darwin11-as -arch i386 -force_cpusubtype_ALL -o /tmp/ccAmbCNm.o /tmp/ccRz0P7k.s
COMPILER_PATH=/home/cosmin/osxcross/target/bin/../libexec/gcc/x86_64-apple-darwin11/5.2.0/:/home/cosmin/osxcross/target/bin/../libexec/gcc/:/home/cosmin/osxcross/target/bin/
LIBRARY_PATH=/home/cosmin/osxcross/target/bin/../lib/gcc/x86_64-apple-darwin11/5.2.0/i386/:/home/cosmin/osxcross/target/bin/../lib/gcc/x86_64-apple-darwin11/5.2.0/../../../../x86_64-apple-darwin11/lib/i386/:/home/cosmin/osxcross/target/bin/../lib/gcc/x86_64-apple-darwin11/5.2.0/:/home/cosmin/osxcross/target/bin/../lib/gcc/:/home/cosmin/osxcross/target/bin/../lib/gcc/x86_64-apple-darwin11/5.2.0/../../../../x86_64-apple-darwin11/lib/:/home/cosmin/osxcross/target/bin/../SDK/MacOSX10.7.sdk/usr/lib/
COLLECT_GCC_OPTIONS='-static-libgcc' '-static-libstdc++' '-isystem' '/home/cosmin/osxcross/target/bin/../SDK/MacOSX10.7.sdk' '-mmacosx-version-min=10.5.0' '-m32' '-v' '-mtune=core2'
/home/cosmin/osxcross/target/bin/../libexec/gcc/x86_64-apple-darwin11/5.2.0/collect2 -dynamic -arch i386 -macosx_version_min 10.5.0 -syslibroot /home/cosmin/osxcross/target/bin/../SDK/MacOSX10.7.sdk -weak_reference_mismatches non-weak -o a.out -lcrt1.10.5.o -L/home/cosmin/osxcross/target/bin/../lib/gcc/x86_64-apple-darwin11/5.2.0/i386 -L/home/cosmin/osxcross/target/bin/../lib/gcc/x86_64-apple-darwin11/5.2.0/../../../../x86_64-apple-darwin11/lib/i386 -L/home/cosmin/osxcross/target/bin/../lib/gcc/x86_64-apple-darwin11/5.2.0 -L/home/cosmin/osxcross/target/bin/../lib/gcc -L/home/cosmin/osxcross/target/bin/../lib/gcc/x86_64-apple-darwin11/5.2.0/../../../../x86_64-apple-darwin11/lib -L/home/cosmin/osxcross/target/bin/../SDK/MacOSX10.7.sdk/usr/lib -no_compact_unwind /tmp/ccAmbCNm.o -lgcc_eh -lgcc -lSystem -v
collect2 version 5.2.0
/home/cosmin/osxcross/target/bin/../bin/x86_64-apple-darwin11-ld -dynamic -arch i386 -macosx_version_min 10.5.0 -syslibroot /home/cosmin/osxcross/target/bin/../SDK/MacOSX10.7.sdk -weak_reference_mismatches non-weak -o a.out -lcrt1.10.5.o -L/home/cosmin/osxcross/target/bin/../lib/gcc/x86_64-apple-darwin11/5.2.0/i386 -L/home/cosmin/osxcross/target/bin/../lib/gcc/x86_64-apple-darwin11/5.2.0/../../../../x86_64-apple-darwin11/lib/i386 -L/home/cosmin/osxcross/target/bin/../lib/gcc/x86_64-apple-darwin11/5.2.0 -L/home/cosmin/osxcross/target/bin/../lib/gcc -L/home/cosmin/osxcross/target/bin/../lib/gcc/x86_64-apple-darwin11/5.2.0/../../../../x86_64-apple-darwin11/lib -L/home/cosmin/osxcross/target/bin/../SDK/MacOSX10.7.sdk/usr/lib -no_compact_unwind /tmp/ccAmbCNm.o -lgcc_eh -lgcc -lSystem -v
253.3
configured to support archs: armv4t armv5 armv6 armv7 armv7f armv7k armv7s armv6m armv7m armv7em armv8 arm64 arm64v8 i386 x86_64 x86_64h (tvOS)
Library search paths:
/home/cosmin/osxcross/target/lib/gcc/x86_64-apple-darwin11/5.2.0/i386
/home/cosmin/osxcross/target/x86_64-apple-darwin11/lib/i386
/home/cosmin/osxcross/target/lib/gcc/x86_64-apple-darwin11/5.2.0
/home/cosmin/osxcross/target/lib/gcc
/home/cosmin/osxcross/target/x86_64-apple-darwin11/lib
/home/cosmin/osxcross/target/SDK/MacOSX10.7.sdk/usr/lib
/home/cosmin/osxcross/target/bin/../SDK/MacOSX10.7.sdk/usr/lib
Framework search paths:
/home/cosmin/osxcross/target/bin/../SDK/MacOSX10.7.sdk/System/Library/Frameworks/
/home/cosmin/osxcross/target/bin/nm -n /tmp/ccAmbCNm.o
collect2: fatal error: /home/cosmin/osxcross/target/bin/nm returned 255 exit status
compilation terminated.
My confusion about gcc comes from this: on OSX, gcc is only a frontend for clang, so when invoking gcc on OSX, you're actually building with clang/llvm. Is this the same thing that ./build_gcc is supposed to create? A clang frontend? Or did I get this all wrong? What I'm trying to say is that I want to produce an OSX binary with the gcc
command. For that I need to build gcc in addition to clang, right?
from osxcross.
My confusion about gcc comes from this: on OSX, gcc is only a frontend for clang, ...
You are talking about Apple's LLVM GCC (GCC is the frontend, LLVM the backend).
so when invoking gcc on OSX, you're actually building with clang/llvm.
Well, that's true for Xcode 6+ (or 5+, I don't really know anymore), but not for older versions.
Older versions used GCC 4.2.1 as frontend and LLVM as backend.
Nowadays Xcode's GCC command is just a wrapper around clang, you can find the sources for the Xcode GCC command here:
Edit: Typo: It's of course a wrapper around clang, not GCC!
https://opensource.apple.com/source/gcc_select/gcc_select-133/gcc.c.
I want to produce an OSX binary with the gcc command. For that I need to build gcc in addition to clang, right?
Do you really need GCC? Does your project not build with clang?
Do you have x86_64-apple-darwinXX-nm
in target/bin
?
If yes, then please also post the output of: strace ./o32-gcc ../../oclang/test.c -v
from osxcross.
Forgot to answer your actual question: Here we are building a vanilla GNU GCC, not the Xcode/Apple one.
from osxcross.
Please close this, sorry for the noise. It was my fault (I created wrappers for all the binaries that doesn't include the prefix, but that doesn't seem to work for some reason -- I suppose I need to find another way to get prefix-free names for the binaries)
from osxcross.
Yes, the triple is read from the invocation name. You could theoretically create another wrapper to wrap the wrapper... symlinking won't work.
from osxcross.
Thanks for the detailed answer about gcc. Looking at gcc.c it looks like clang and gcc have exactly the same command line options and no translation is really necessary. I mean that code almost doesn't do anything which is surprising. Which makes me wonder why would I need to build gcc for anything then when I could just wrap clang as gcc?
About why I need gcc, I actually just need a compatible cmdline UI. The reason is that I don't have one project, I have some 40 libs to compile and I'd like to do so without changing the build scripts :) But now that I know that gcc and clang are basically the same thing to the user except the binary name, that opens up more options.
(about wrapping, it does indeed work with a one-liner exec blah "$@"
)
Thanks again for all the help. Moving on...
from osxcross.
Which makes me wonder why would I need to build gcc for anything then when I could just wrap clang as gcc?
I don't want to follow Apple's approach, it just causes confusion.
And there's still code that won't build with clang, or for people who prefer the use of GCC over clang, or for projects where GCC generates faster code, etc. etc.. :-)
from osxcross.
apple killed gcc after steve passed away. what you got there is a convenient clang / llvm. it is not mean for real software engineers, it is meant for end losers, with a mouse over xcode. no wonder they lost any presence in server and cloud. release after release, they made it more and more difficult to use real tool under their so called operating system
from osxcross.
Related Issues (20)
- build_gcc.sh does not install needed prerequisites. HOT 2
- flang support HOT 1
- Add FAQ HOT 3
- error in osxcross build HOT 5
- RFE: macports variants
- stdlib.h missing from xar/lib/linuxattr.c HOT 2
- install_name_tool doesn't adjust ad-hoc code signatures HOT 1
- Error while packaging HOT 3
- Fialed to cross compile apple darwin target HOT 5
- This header is only meant to be used on x86 and x64 architecture HOT 2
- target-cpu
- ld64.lld: error: undefined symbol: __cpu_model HOT 1
- Support for xcrun --show-sdk-platform-version HOT 4
- GCC compilation is not working HOT 1
- support for asahi linux, getting the following error error while loading shared libraries: libicui18n.so.74 HOT 1
- Not working when CMAKE_GENERATOR=Ninja
- Request: Set osxcross-specific compiler path
- cann't build compiler_rt with custom TARGET_DIR
- x86_64-apple-darwin23.3-gcc: error: unrecognized command-line option '-fobjc-link-runtime' HOT 1
- Cannot build using XCode 16.1 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from osxcross.