Page 2 of 4
Re: [UEFI bare bones/x-compiler config] - LD not finding li
Posted: Wed Jan 06, 2021 3:26 pm
by xenos
I suspect that on these systems libgcc is built as a shared library instead of a static one. (I haven't checked, since I haven't targeted any of those recently.)
Re: [UEFI bare bones/x-compiler config] - LD not finding li
Posted: Wed Jan 06, 2021 3:28 pm
by Schol-R-LEA
If so, is there a straightforward way to force it to be built as a static library?
And are there any notable reasons why not to do so, and if so, how do I work around them? I can understand why those triplets would default to that, given that those target triplets are meant mainly for systems which support DLLs/shared libraries, but I would expect that there would be times when a static version would be called for even in general programming practice.
Re: [UEFI bare bones/x-compiler config] - LD not finding li
Posted: Wed Jan 06, 2021 3:30 pm
by nexos
Try passing --disable-shared to configure
Re: [UEFI bare bones/x-compiler config] - LD not finding li
Posted: Wed Jan 06, 2021 3:33 pm
by Octocontrabass
Re: [UEFI bare bones/x-compiler config] - LD not finding li
Posted: Wed Jan 06, 2021 3:35 pm
by Schol-R-LEA
nexos wrote:Try passing --disable-shared to configure
OK, I'll try that now. I assume that this applies only to GCC, and not to the build for binutils - though I suppose it could, for the assembler and linker.
EDIT: For the time being, I am passing it to
configure in both scripts, though I don't expect it has any effect on Binutils.
Re: [UEFI bare bones/x-compiler config] - LD not finding li
Posted: Wed Jan 06, 2021 3:37 pm
by nexos
Schol-R-LEA wrote:If so, is there a straightforward way to force it to be built as a static library?
And are there any notable reasons why not to do so, and if so, how do I work around them? I can understand why those triplets would default to that, given that those target triplets are meant mainly for systems which support DLLs/shared libraries, but I would expect that there would be times when a static version would be called for even in general programming practice.
There is a good chance it is building shared libraries. Windows itself does support DLLs, so libgcc ought to be build as a DLL. For freestanding environments, shared libraries won't be supported (at least at first), so we must tell configure to not use shared libs. But as Octocontrabass said, the docs are unclear as to what the defaults are.
Re: [UEFI bare bones/x-compiler config] - LD not finding li
Posted: Wed Jan 06, 2021 3:39 pm
by Schol-R-LEA
Very well, then. I will let you know the results when the builds finish.
Re: [UEFI bare bones/x-compiler config] - LD not finding li
Posted: Wed Jan 06, 2021 11:13 pm
by Schol-R-LEA
OK, I ran the script as it was, and got the following error:
Code: Select all
checking how to run the C preprocessor... /lib/cpp
configure: error: in `/home/schol-r-lea/Deployments/cross-dev-utils/gcc/build/x86_64-w64-mingw32/x86_64-w64-mingw32/libgcc':
configure: error: C preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details
make: *** [Makefile:13779: configure-target-libgcc] Error 1
This is the first time this error has come up so far, but it does indicate that it is at least trying to build libgcc, even if there is some problem with the C pre-processor.
I have composed a simplified version of the install script to speed up the testing, having it compile only for the single target triplet, and only for C:
Code: Select all
#!/bin/bash
GCC_SRC="/home/schol-r-lea/Deployments/cross-dev-utils/gcc"
GCC_BUILD="$GCC_SRC/build"
DEST="/home/schol-r-lea/opt/cross"
cd $GCC_SRC
# git pull origin master
cd $GCC_BUILD
TARGET="x86_64-w64-mingw32"
TARGET_DIR="$GCC_BUILD/$TARGET"
if [ ! -d $TARGET_DIR ]; then
mkdir -p $TARGET_DIR
fi
cd $TARGET_DIR
$GCC_SRC/configure --target=$TARGET --prefix=$DEST --disable-nls \
--enable-languages=c \
--disable-shared \
--without-headers
make all-gcc
make all-target-libgcc
make install-gcc
make install-target-libgcc
Running this gives the following error message:
Code: Select all
/usr/bin/install -c -m 644 b-header-vars /home/schol-r-lea/opt/cross/lib/gcc/x86_64-w64-mingw32/11.0.0/plugin/include/b-header-vars
make[1]: Leaving directory '/home/schol-r-lea/Deployments/common/gcc/build/x86_64-w64-mingw32/gcc'
/bin/sh /home/schol-r-lea/Deployments/cross-dev-utils/gcc/mkinstalldirs /home/schol-r-lea/opt/cross /home/schol-r-lea/opt/cross
make[1]: Entering directory '/home/schol-r-lea/Deployments/common/gcc/build/x86_64-w64-mingw32/x86_64-w64-mingw32/libgcc'
make[1]: *** No rule to make target 'install'. Stop.
make[1]: Leaving directory '/home/schol-r-lea/Deployments/common/gcc/build/x86_64-w64-mingw32/x86_64-w64-mingw32/libgcc'
make: *** [Makefile:13221: install-target-libgcc] Error 2
What I don't understand about this error is the reference to a
common/ directory in the directory
above the one I am invoking the script from (
/home/schol-r-lea/Deployments/cross-dev-utils). I would expect that, if anything, it would use a
common/ directory in
/home/schol-r-lea/Deployments/cross-dev-utils/gcc, rather than going two directories up the path.
EDIT: While the
/home/schol-r-lea/Deployments/common/ directory does exist, which is where all of the actual source code is kept (the directories in
cross-dev-utils/ are all symbolic links to same, something I'd forgotten about) there is no
libgcc/ directory there.
I know I am building from the bleeding-edge versions of the GCC source tree, but I am hesitant to assume that there is a fault in the GCC build scripts. I can only assume something is wrong with my own script, but I am unsure what it would be.
Re: [UEFI bare bones/x-compiler config] - LD not finding li
Posted: Wed Jan 06, 2021 11:49 pm
by kzinti
Give 10.2.0 a try perhaps? I am building it with no problems for i686-elf and x86_64-elf.
I use binutils 2.35, GCC 10.2.0 and newlib 4.0.0. Perhaps not "bleeding edge" but the latest official release.
Re: [UEFI bare bones/x-compiler config] - LD not finding li
Posted: Wed Jan 06, 2021 11:52 pm
by Schol-R-LEA
kzinti wrote:Give 10.2.0 a try perhaps? I am building it with no problems for i686-elf and x86_64-elf.
I use binutils 2.35, GCC 10.2.0 and newlib 4.0.0. Perhaps not "bleeding edge" but the latest official release.
That would make sense to at least try, OK.
EDIT: No change. Do I need to download or clone the source code for LibGCC separately from the GCC code?
Re: [UEFI bare bones/x-compiler config] - LD not finding li
Posted: Thu Jan 07, 2021 12:11 am
by kzinti
I use zipped source code from here:
http://ftp.gnu.org/gnu/binutils/
http://ftp.gnu.org/gnu/gcc/gcc-10.2.0/
libgcc comes with gcc, there is no separate download.
Re: [UEFI bare bones/x-compiler config] - LD not finding li
Posted: Thu Jan 07, 2021 10:05 pm
by Schol-R-LEA
I tried compiling the 10.2.0 release, but got the same results.
On going back to the Master build, I removed the --enable-languages option, since it seems that the default is to build all supported languages for a given target triplet, which is what I actually want.
Also, I am getting the error about the C preprocessor failing a sanity check, again. This leads me to a question: given that cpp is a separate program from the compiler, is it bundled with Binutils, or with GCC? Do they both include their own versions? Or is there a separate package for cpp which I ought to download?
Since it is apparently using the system version at lib/cpp, would the mismatch in versions (10.2.0 vs. 11.0.0) be a factor?
Re: [UEFI bare bones/x-compiler config] - LD not finding li
Posted: Fri Jan 08, 2021 12:16 pm
by Schol-R-LEA
As a quick update, I had a brainfart last night and tried pulling the 10.2.0 tagged branch over my current local, rather than using switch, the practical upshot being that I've had to delete my local and clone it fresh. I am currently building both binutils and gcc again, and hopefully by building the releases/gcc-10 branch I'll be able to see if the discrepancy in the versions of cpp was to blame for the most recent problem.
Re: [UEFI bare bones/x-compiler config] - LD not finding li
Posted: Fri Jan 08, 2021 5:01 pm
by Schol-R-LEA
OK, so I am still getting the failed sanity check error regarding the default version of the C preprocessor when compiling for releases/gcc-10. Something seems to be off with the Manjaro system install for CPP, or at least, the compiling scripts for libgcc seems to think there is when compiling for this given target triplet and a static version of libgcc.
Is there any way to compile CPP independently, and then force the configuration script to compile with that different version?
For now, I am going to build a separate version of GCC for the dev host target triplet (x86_64-pc-linux-gnu) and use that as a bootstrap for the successive cross compiler builds.
If I can't solve this issue, or if other issues keep arising, I may need to shift to using LLVM/Clang for this project, instead.
Re: [UEFI bare bones/x-compiler config] - LD not finding li
Posted: Fri Jan 08, 2021 5:39 pm
by nexos
How come you don't just just install the mingw packages from APT? That would be a lot easier. I have had many problems with Clang, so I would stay away from it.