Talk:OS Specific Toolchain: Difference between revisions

Content deleted Content added
Max (talk | contribs)
No edit summary
 
(5 intermediate revisions by 3 users not shown)
Line 1:
'''Proposal:''' I think we should simplify this page and remove the binutils part about the emulparams. It is not really necessary to create custom emulparams since those existing for the target should be sufficient (elf_i386/elf_x86_64 in this case). This makes the whole setup simpler since automake'ing isn't required anymore either. What do you think? --[[User:Max|Max]] 14:00, 11 October 2022 (CDT)
 
 
----
 
 
'''Excellent''' work! As for how to continue with this... I was originally intending what is the GCC Cross-Compiler article today to become a multi-part tutorial, starting with the cross-compiler setup and ending with a self-supporting OS. You can see the stubs for the later steps in the article.
Of course I would prefer that tutorial to include PDCLib instead of newlib, but newlib is available today. Maybe it's time to expand the cross-compiler tut. into the multi-part thing it was originally meant to be?
Line 55 ⟶ 61:
== Implementation notes ==
This tutorial has worked for me with GCC 4.5.0 and Newlib 1.18.0. I came across two errors when compiling Newlib. The first was exactly the same as in [forum:17777 this thread], but this was because there were compilation errors in my system call stubs; my best guess is that Make would try to compile them, fail, abort the entire compile process, then continue onwards assuming that it had succeeded. The second error was when I ran 'make install'. /usr/bin/install couldn't stat newlib/libc/sys/myos/netinet/*.h. For lack of a better way to disable networking (I presume) functionality, I simply created the folder structure as indicated and created an empty file, Net.h. This could probably be done better, but for a quick and dirty hack it seems to work. --[[User:Computafreak|Computafreak]] 09:41, 30 August 2010 (UTC)
 
I tried this with bleeding edge binutils-2.22, gcc-4.6.2 and newlib-1.20.0. I had a few issues, the most important one is that gettimeofday() syscall is wrong. Removing the row made it compile but should probably be changed. Also I had to add --without-headers and --with-newlib when running configure for gcc --[[User:Jezze|Jezze]] 22:27, 6 January 2012 (CST)
 
== Binutils not building GNU gold linker ==
 
Even when adding <tt>--enable-gold --enable-lto --enable-plugins</tt> to the Binutils configure script, the gold linker is not being built. It is built for the target <tt>i686-pc-elf</tt>, but not <tt>i686-pc-myos</tt>. I'm not sure whether you have to enable gold for the ''myos'' target and where. It seems that <tt>$SRC/gold/configure.tgt</tt> does not require any changes. I just wanted to mention this. Using binutils-2.21. --[[User:Walling|Walling]] 21:5557, 7 April 2011 (UTC)
 
:I found the answer. You have to enable the gold linker for your target. It is easily done in the main configure.ac file. Look for <tt>Handle --enable-gold, --enable-ld</tt> and find the line <tt># Check for ELF target.</tt> Now add your target in the <tt>case "${target}"</tt>. I added <tt>*-*-myos*</tt> after <tt>*-*-irix6*</tt>, because there was some space left. Then run <tt>autoconf</tt> in the same directory as the configure.ac file. It will generate a new configure script. Now you're able to configure (in a build directory) and make. --[[User:Walling|Walling]] 13:24, 8 April 2011 (UTC)
 
== Newlib sys/myos Makefile.am problem ==
 
It appears that in newer versions of Newlib (I'm trying to use 2.1.0), if you create the Makefile.am for your system as suggested below:
 
if MAY_SUPPLY_SYSCALLS
extra_objs = syscalls.o
else
extra_objs =
endif
 
than, the extra_objs assignment is added after the rest of the assignments in the actual Makefile. So, for example, in the Makefile (after configuration) it would look something like this:
 
lib_a_SOURCES =
lib_a_LIBADD = $(extra_objs)
EXTRA_lib_a_SOURCES = syscalls.c crt0.S
lib_a_DEPENDENCIES = $(extra_objs)
lib_a_CCASFLAGS = $(AM_CCASFLAGS)
lib_a_CFLAGS = $(AM_CFLAGS)
... # A lot of other stuff, approximately 300 lines
extra_objs = syscalls.o
# extra_objs =
 
This makes lib_a_LIBADD empty, and therefore never compiles your syscalls. The solution is to remove the conditional and make it simply:
 
extra_objs = syscalls.o
 
It was a rather annoying bug to track down. I'm not sure of the ramifications of ignoring the MAY_SUPPLY_SYSCALLS macro, but I am currently ignoring it and newlib is compiling happily. I assume this is happening because the configure script/automake makes two passes. First evaluating assignments and adding them all to the script, then second evaluating all conditionals and adding remaining assignments to the script. So on pass one, all the variables are dumped into the Makefile, then the if block is tested and extra_objs is placed inside the Makefile after all the other assignments (which in this case is a problem). --[[User:Caleb1994|Caleb1994]] 17:11, 4 September 2014 (CDT)
Return to "OS Specific Toolchain" page.