Unable to compile a cross-compiler
Hi. I'm trying to build three cross compilers. I'm building an OS and I'm using the aarch64-w64-mingw32 package. But no matter what I add, remove, flags used, it just won't compile. I have all the right apps, all the right libraries (I think. I only compiled gmp, mpfr, and mpc), and all the right flags, but it doesn't work. How do I fix this?
P.S. I'm building the following targets:
i686-elf
x86_64-elf
arm-none-eabi (for Raspberry Pis)
So you want to build compilers that are going to target i686-elf, x86_64-elf and arm-none-eabi - and you are going to run those compilers on Windows on aarch64? In what environment are you building, what commands do you execute, on what source package, and what errors do you get when you do that?
I am going to run these packages on Windows on ARM. Since I'm running WoA on my Raspberry Pi 4, I want as much as possible to be ARM binaries, because the x86 emulation doesn't run very well on my Pi (it is not broken, just it is slow). I have only managed to compile nasm and ndisasm. I run the build in MSYS2. I use gcc-11.2.0 and binutils-2.37. I'm configuring binutils with these commands and gcc with these commands. I will provide the errors soon.
I tried using cygwin to see if it would let me compile, but it didn't.
I got the following errors when compiling binutils:
aarch64-w64-mingw32-gcc -c -DHAVE_CONFIG_H -g -O2 -I. -I../../binutils-2.37/libiberty/../include -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -Wshadow=local -pedantic -D_GNU_SOURCE ../../binutils-2.37/libiberty/rust-demangle.c -o rust-demangle.o warning: unknown warning option '-Wshadow=local' [-Wunknown-warning-option] ../../binutils-2.37/libiberty/rust-demangle.c:78:3: error: unknown type name 'uint'; did you mean 'int'? uint recursion; ^~~~ int ../../binutils-2.37/libiberty/rust-demangle.c:680:25: error: use of undeclared identifier 'uint'; did you mean 'int'? if (rdm->recursion != RUST_NO_RECURSION_LIMIT) ^ ../../binutils-2.37/libiberty/rust-demangle.c:81:37: note: expanded from macro 'RUST_NO_RECURSION_LIMIT' #define RUST_NO_RECURSION_LIMIT ((uint) -1) ^ ../../binutils-2.37/libiberty/rust-demangle.c:680:25: error: reference to overloaded function could not be resolved; did you mean to call it? if (rdm->recursion != RUST_NO_RECURSION_LIMIT) ^~~~~~~~~~~~~~~~~~~~~~~ ../../binutils-2.37/libiberty/rust-demangle.c:81:36: note: expanded from macro 'RUST_NO_RECURSION_LIMIT' #define RUST_NO_RECURSION_LIMIT ((uint) -1) ^~~~~~ ../../binutils-2.37/libiberty/rust-demangle.c:798:25: error: use of undeclared identifier 'uint'; did you mean 'int'? if (rdm->recursion != RUST_NO_RECURSION_LIMIT) ^ ../../binutils-2.37/libiberty/rust-demangle.c:81:37: note: expanded from macro 'RUST_NO_RECURSION_LIMIT' #define RUST_NO_RECURSION_LIMIT ((uint) -1) ^ ../../binutils-2.37/libiberty/rust-demangle.c:798:25: error: reference to overloaded function could not be resolved; did you mean to call it? if (rdm->recursion != RUST_NO_RECURSION_LIMIT) ^~~~~~~~~~~~~~~~~~~~~~~ ../../binutils-2.37/libiberty/rust-demangle.c:81:36: note: expanded from macro 'RUST_NO_RECURSION_LIMIT' #define RUST_NO_RECURSION_LIMIT ((uint) -1) ^~~~~~ ../../binutils-2.37/libiberty/rust-demangle.c:1341:55: error: use of undeclared identifier 'uint'; did you mean 'int'? rdm.recursion = (options & DMGL_NO_RECURSE_LIMIT) ? RUST_NO_RECURSION_... ^ ../../binutils-2.37/libiberty/rust-demangle.c:81:37: note: expanded from macro 'RUST_NO_RECURSION_LIMIT' #define RUST_NO_RECURSION_LIMIT ((uint) -1) ^ ../../binutils-2.37/libiberty/rust-demangle.c:1341:55: error: reference to overloaded function could not be resolved; did you mean to call it? ...= (options & DMGL_NO_RECURSE_LIMIT) ? RUST_NO_RECURSION_LIMIT : 0; ^~~~~~~~~~~~~~~~~~~~~~~ ../../binutils-2.37/libiberty/rust-demangle.c:81:36: note: expanded from macro 'RUST_NO_RECURSION_LIMIT' #define RUST_NO_RECURSION_LIMIT ((uint) -1) ^~~~~~ 1 warning and 7 errors generated. make[2]: *** [Makefile:1230: rust-demangle.o] Error 1 make[2]: Leaving directory '/cygdrive/c/src/binutils-build/libiberty' make[1]: *** [Makefile:8152: all-libiberty] Error 2 make[1]: Leaving directory '/cygdrive/c/src/binutils-build' make: *** [Makefile:915: all] Error 2
Is there some way I can disable rust? My OS is in assembly, C, and C++. I have no need for rust.
Or do I need to disable libiberty? That seems like it might work, so I'll try it.
I will provide the GCC errors soon.
So I disabled libiberty and got pretty far in the build. But when it started compiling libbfd, I was given this error from libtool:
lib: command not found.
I'm going to see if I can disable libbfd.
All I'm hoping for is a successful build that generates and modifies code properly, and the code runs like it was made to.
As of now, I'm disabling opcodes.
I tried using cygwin to see if it would let me compile, but it didn't. I got the following errors when compiling binutils:
aarch64-w64-mingw32-gcc -c -DHAVE_CONFIG_H -g -O2 -I. -I../../binutils-2.37/libiberty/../include -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -Wshadow=local -pedantic -D_GNU_SOURCE ../../binutils-2.37/libiberty/rust-demangle.c -o rust-demangle.o warning: unknown warning option '-Wshadow=local' [-Wunknown-warning-option] ../../binutils-2.37/libiberty/rust-demangle.c:78:3: error: unknown type name 'uint'; did you mean 'int'? uint recursion; ^~~~ int ../../binutils-2.37/libiberty/rust-demangle.c:680:25: error: use of undeclared identifier 'uint'; did you mean 'int'?
This is a known issue in binutils 2.37, see https://sourceware.org/pipermail/binutils/2021-September/117993.html for a report on it. It was fixed in the binutils 2.37 branch in https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=999566402e3d7c69032bbf47e28b44fc0926fe62, and that patch was backported in MSYS2's own build of binutils here: https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-binutils/0600-Change-uint-to-unsigned.patch
So I disabled
libibertyand got pretty far in the build. But when it started compilinglibbfd, I was given this error fromlibtool:lib: command not found.I'm going to see if I can disablelibbfd. All I'm hoping for is a successful build that generates and modifies code properly, and the code runs like it was made to.
You can't disable libbfd, that's the core part of binutils for actually writing object files.
It sounds surprising to me that something tries to execute lib here, which is a tool from MSVC. You'd have to try to figure out why it tries to do that, to see what you should do to make it not call that.
Ideally you'd first do one working reference build, in msys2 on x86, with regular gcc, that works. When that works, you could try to switch to building with llvm-mingw for an x86_64 target in the same environment, and for any issue, look into what differs (in various logs etc). Once that works, change x86_64 into aarch64.
Alright, I'll try that.
I've been trying to build it for so long.
When everything seems like it's working, it all breaks.
If you could try and build it and help me figure this out, that would help. A lot.
Thanks. I'll start by just building ld and as (for llvm-mingw gcc).
Thanks for all your help.
I applied that patch to the code and I will use this for the llvm-mingw x86_64 and aarch64 builds.
I'm having trouble compiling binutils.
It stops at rm -rf $backupdir; exit $rc.
I try to close it, and then it continues.
And then it says gcc.exe: fatal error: no input files.
What do I do?
I'm having trouble compiling binutils. It stops at
rm -rf $backupdir; exit $rc. I try to close it, and then it continues. And then it saysgcc.exe: fatal error: no input files. What do I do?
Sorry, I don't know based just on this. You'd have to try to debug what goes wrong before that, and why.
Hey. I left my PC on overnight and it is still frozen.
On Thu, Feb 3, 2022, 09:04 Martin Storsjö @.***> wrote:
I'm having trouble compiling binutils. It stops at rm -rf $backupdir; exit $rc. I try to close it, and then it continues. And then it says gcc.exe: fatal error: no input files. What do I do?
Sorry, I don't know based just on this. You'd have to try to debug what goes wrong before that, and why.
— Reply to this email directly, view it on GitHub https://github.com/mstorsjo/llvm-mingw/issues/256#issuecomment-1029081663, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWYQOASV5KTHBZ3HDPZV7OTUZKKQDANCNFSM5NK47ZFQ . You are receiving this because you authored the thread.Message ID: @.***>
I'm having trouble compiling binutils. It stops at
rm -rf $backupdir; exit $rc. I try to close it, and then it continues. And then it saysgcc.exe: fatal error: no input files. What do I do?Sorry, I don't know based just on this. You'd have to try to debug what goes wrong before that, and why.
Can you help me debug? Or tell me how? I'm not that great at exploring the inside of tools. I've had my own little fear of seeing how something works and breaking everything beyond repair.
I'm having trouble compiling binutils. It stops at
rm -rf $backupdir; exit $rc. I try to close it, and then it continues. And then it saysgcc.exe: fatal error: no input files. What do I do?Sorry, I don't know based just on this. You'd have to try to debug what goes wrong before that, and why.
Can you help me debug? Or tell me how? I'm not that great at exploring the inside of tools. I've had my own little fear of seeing how something works and breaking everything beyond repair.
Sorry, I can’t really give instructions on how to debug it and what to do; to be able to give such instructions, I would have to debug it myself first and explain all the steps I did.
I might look into it at some point, but I can’t give any promises…
I'm having trouble compiling binutils. It stops at
rm -rf $backupdir; exit $rc. I try to close it, and then it continues. And then it saysgcc.exe: fatal error: no input files. What do I do?Sorry, I don't know based just on this. You'd have to try to debug what goes wrong before that, and why.
Can you help me debug? Or tell me how? I'm not that great at exploring the inside of tools. I've had my own little fear of seeing how something works and breaking everything beyond repair.
Sorry, I can’t really give instructions on how to debug it and what to do; to be able to give such instructions, I would have to debug it myself first and explain all the steps I did.
I might look into it at some point, but I can’t give any promises…
I wasn't really asking how to debug mine, I'm only wondering how do I debug. What tool do I need? Stuff like that.
I'm having trouble compiling binutils. It stops at
rm -rf $backupdir; exit $rc. I try to close it, and then it continues. And then it saysgcc.exe: fatal error: no input files. What do I do?Sorry, I don't know based just on this. You'd have to try to debug what goes wrong before that, and why.
Can you help me debug? Or tell me how? I'm not that great at exploring the inside of tools. I've had my own little fear of seeing how something works and breaking everything beyond repair.
Sorry, I can’t really give instructions on how to debug it and what to do; to be able to give such instructions, I would have to debug it myself first and explain all the steps I did. I might look into it at some point, but I can’t give any promises…
I wasn't really asking how to debug mine, I'm only wondering how do I debug. What tool do I need? Stuff like that.
You need a text editor and patience. Running a working reference test case, comparing things with a failing case that otherwise is as similar as possible. Then look for differences, try to figure out why things differ, and what can be done about it.
That’s how you debug compilation issues in general.
It isn't really a compilation issue (I think). Whenever I go to close down the window, there is one process that concerns me:
/usr/bin/sh -c fail=; \
I got past building the documentation! Now there is an error in the Makefile. It stops because of:
gcc.exe: fatal error: no input files
It happens I think from the command:
gcc -DHAVE_CONFIG_H -I. -I../../binutils-2.37/bfd "-DBINDIR=\\C:/test/normalGcc/bin\" -DLIBDIR=\"C:/test/normalGcc/lib\" -I. -I../../binutils-2.37/bfd -I../../binutils-2.37/bfd/../include -DHAVE_i386_elf32_vec -DHAVE_iamcu_elf32_vec -DHAVE_i386_coff_vec -DHAVE_elf32_le_vec -DHAVE_elf32_be_vec -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -I../../binutils-2.37/bfd/../zlib -g -O2 -MT archive.lo -MD -MP -MF .deps/archive.Tpo -c -o archive.lo ../../binutils-2.37/bfd/archive.c" -o archive.o
I think the error is from ../binutils-2.37/bfd/archive.c" because it is missing a quotation mark. How can I change this?
Hey. Sorry if I bothered you about the cross compiler thing. I did manage to compile binutils 2.28 for ARM64. If you want I can share the package. I compiled this package with:
../binutils-2.28/configure --host="aarch64-w64-mingw32" --target="arm-none-eabi" --prefix="/c/compile/binutils" --with-sysroot --disable-nls --disable-werror
I will probably recompile it with more flags like --disable-shared --enable-static.
Hey. So I'm trying something with gcc. At a certain point in the build, gcc will start using the build system, which for me is i686-pc-msys. I read some complaints about the build failing when building a file called libiberty/pex-unix.c. So, if I'm right, gcc can't recognize msys in the build system type. I'm testing this right now.
P.S. I also built the i686-elf binutils for WoA64.
Hey. The llvm-mingw compiler is missing sys/wait.h. Do you have a copy?
Hey. I'm getting an error trying to compile gcc 7.1.0. Whenever it tries to run a self test, it gives me the error nul: invalid argument. How do I fix it?