Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
I've always used linux to assemble/link my os modules but now it'd be a lot more convenient to do it on my mac. It's become pretty apparent that the versions of ld for linux and mac are different. For example, the mac version doesn't support linker scripts. However, this isn't my problem. My problem is that when I link, I get an output file that is much too large. I'm building from scratch, just a blank screen boot loader. Code
May be some problem with section alignment.
Ah, you said that it didn't support linker script which means there's not much you can do.
So, the only recommendation here, is a Cross Compiler.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
I suggest to use fasm it works perfectly under OSX (http://board.flatassembler.net/download.php?id=3707). And forget llvm, you can download the usual toolchain for free from apple (gnu make, gcc and their friends, or, if you have purchased the OS with your machine you should have a 2nd disc that contains developer tools). But you have to compile gcc to have a cross-compiler (recommended but hard), or you can convert the binary by objconv (not nice, but works).
Apple's toolchain is on crack: it's specifically tuned to produce binaries for Steve's platforms. I struggled for too long to maintain an ELF-targeting GNU GCC on my OS X machine (built by the XCode toolchain) until I figured it was easier to use crosstool-ng on Linux to set up a cross-compiler. Grab a spare PC, slap Linux on it and hook it up to your network as a headless build server, or get VMWare for your Mac.
If you found that the GCC Cross-Compiler tutorial didn't work for you, please do give according feedback, e.g. on the discussion page of the article, the OSDev Wiki subforum, or (while we're at it) in this thread.
The tutorial has proven to be easy enough for most people, both on Windows and Linux. I don't see why it should not be just as easy on MacOS. The advantages of having one way that works on all three platforms should be obvious.
As of now, the only Mac-specific thing I see is that apparently you need to update libiconv beforehand. Anything else that didn't work for you on MacOS?
Every good solution is obvious once you've found it.
Solar wrote:As of now, the only Mac-specific thing I see is that apparently you need to update libiconv beforehand. Anything else that didn't work for you on MacOS?
My apologies. It was possible to get a basic toolchain working without the wiki because I was initially building the kernel and simple userland binaries with a cross-compiling GCC and nasm that were built on OS X.
However when it came to porting newlib to my OS it wasn't possible to follow the wiki because Apple's toolchain is not generic and is tuned to produce software for their platforms to the point where (in my experience) the tutorial can't be followed to build a full cross-compiling toolchain without replacing lots of utilities - at which point I might as well just switch to Linux.
I've long since erased memories of staying up all night trying to set up a full cross-compiler on Mac OS X. I'm glad I did as I now have multiple toolchains targeting x86. x64 and ARM thanks to crosstool-ng on a Ubuntu build server with code edited and docs viewed on the Apple desktop.
I just got a new mac the other day. I did a basic install then added xcode from the mac install disc, which installs gcc. I didn't install anything else at all.
I built a cross-binutils and cross-gcc with the mac tool-chain and then built newlib with my cross-toolchain. All that I needed to download are the obvious
binutils
gcc
gmp
mpc
mpfr
newlib
None of that mac-ports stuff is needed.
Maybe I better check the wiki to see whether I deviated from it at all. It seems very straight-forward to me. (But I'm sure I couldn't do it on windows)
If a trainstation is where trains stop, what is a workstation ?
gerryg400 wrote:I just got a new mac the other day. I did a basic install then added xcode from the mac install disc, which installs gcc. I didn't install anything else at all.
I built a cross-binutils and cross-gcc with the mac tool-chain and then built newlib with my cross-toolchain. All that I needed to download are the obvious
binutils
gcc
gmp
mpc
mpfr
newlib
None of that mac-ports stuff is needed.
Maybe I better check the wiki to see whether I deviated from it at all. It seems very straight-forward to me. (But I'm sure I couldn't do it on windows)
When OSX 10.5 first came out, you needed macports just for an updated iconv library (or you could build it yourself). I don't think it's needed anymore though. It's been a while since I've built a cross compiler on OSX, but being as I use my macbook every day, maybe I should update the wiki with newer instructions. Then again, I'm still on 10.5.8, and the laziness bug has struck me.
../gcc-4.5.1/configure --target=$TARGET --prefix=$PREFIX --disable-nls --enable-languages=c,c++ --with-newlib --with-sysroot=$PREFIX
make all-gcc
make install-gcc
make all-target-libgcc
make install-target-libgcc
../newlib-$NEWLIB_VER/configure --target=$TARGET --prefix=$PREFIX
make all
make install
I don't think the tutorial mentions the '--with-sysroot' option. Also I should point out that I've never tried to build a C++ programme with my tool chain.
If a trainstation is where trains stop, what is a workstation ?
turdus wrote:And forget llvm, you can download the usual toolchain for free from apple (gnu make, gcc and their friends, or, if you have purchased the OS with your machine you should have a 2nd disc that contains developer tools).
I wouldn't call Apple's build of gcc generic enough. Objconv you apparently have to build anyway, it's not in default dev tools.
If you forget llvm, you're missing out on the opportunity to have a VERY simple to build crosscompiler (unlike gcc crap, you just need to run two "svn checkout", one mkdir, one cmake and one make command to build ENTIRE cross-compiler). EDIT: Added an article stub about this to the wiki.
The only reason I need crossgcc atm is the fact that clang++ doesn't support lambdas yet.
Fair enough! When I last checked llvm, it was not so easy to set up. Since I do not need a crosscompiler for my OS, my info could be out of date.