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 compiled a cross-compiler for my Mac (macOS 10.13.3 High Sierra) targeting i686-elf using the tutorial on the wiki. When trying to compile my kernel's main c file (I neglected to make a cross-compiler before starting on my OS) with make VERBOSE=1 I get the following:
I am not a mac user, but I am left with the impression that your gcc is trying to use the xcode's assembler, which is also called "as". This assembler is not intended to produce x86 code, so the interaction fails. Google tells me that xcode installs gas as well, but I doubt that it is x86 targeted either. You could check this with "gcc -print-prog-name=as" (which could be different from the one in the path) and then interrogate the executable you are given or use the package manager to tell you its origin.
So. One option is to build (or acquire from somewhere) a cross-targeting binutils and point the gcc configuration with the --with-as and --with-ld options, as described here. Or you could simply set the PATH and I believe the configure script should pick them up. If you want to make a test without rebuilding gcc, you could install the target specific gas and then use the -B option to tell the compiler what (extra) paths to search for binaries and executables. Also check this SO post.
simeonz wrote:I am not a mac user, but I am left with the impression that your gcc is trying to use the xcode's assembler, which is also called "as". This assembler is not intended to produce x86 code, so the interaction fails. Google tells me that xcode installs gas as well, but I doubt that it is x86 targeted either. You could check this with "gcc -print-prog-name=as" (which could be different from the one in the path) and then interrogate the executable you are given or use the package manager to tell you its origin.
So. One option is to build (or acquire from somewhere) a cross-targeting binutils and point the gcc configuration with the --with-as and --with-ld options, as described here. Or you could simply set the PATH and I believe the configure script should pick them up. If you want to make a test without rebuilding gcc, you could install the target specific gas and then use the -B option to tell the compiler what (extra) paths to search for binaries and executables. Also check this SO post.
I ran "gcc -print-prog-name=as" and it did indeed look like gcc was using the xcode installation, so I reconfigured my GCC download with the "--with-as" and "--with-ld" arguments pointing to the path of the i686 as and ld. Making this then produced a working version of i686-elf-gcc, thanks to you both for the help!