Changes

Jump to: navigation, search

LEAP ILP 32

4,319 bytes added, 18:17, 19 August 2015
no edit summary
This page describes the process of creating ILP32 support for LEAP.
 
Current state:
 
At the current state, gcc-ilp32 (gcc-4.9.2) is created to be correctly installed in the separate tree (/opt/ilp32/).
Latest version of gcc can be found here: http://blue/koji/buildinfo?buildID=30942
It correctly produces Aarch64ELF32 files, using the technique, describe below in "Testing ILP32" section.
Binutils 2.24 were created to provide scripts that are needed by the linker to work with ILP32 files. There will not be two different versions of Binutils, only one, with the scripts already there. Latest version can be found here:
http://blue/koji/buildinfo?buildID=30943
 
To do:
 
Currently, we are missing some 32-bit C/C++ libraries. While compiling a file in ilp32 mode is generally successful, some generic C/C++ libraries are present only in 64-bit. To successfully produce 32-bit versions, we need to compile GCC in MultiLib mode, which supposedly will generate those libraries. We found this information after checking the build logs for Fedora gcc, to see at what point and what command 32-bit libraries were generated.
https://kojipkgs.fedoraproject.org//packages/gcc/5.2.1/1.fc22/data/logs/x86_64/build.log build log shows that 32-bit folder was created in libgcc/Makefile.in. There we found that the directory uses default gcc macro to name MULTIOSDIR, which on our builders is different from what it needs to be. We created a patch to hardcode that value to what it needs to be ("32"). Next step was to enable multilib support in gcc-ilp32.spec. For that we added aarch64 architecture to the list of architectures with multilib support.
Unfortunately, to compile a compiler with MultiLib support, one would need to use another existing on the system compiler with MultiLib. Since out gcc was build without such support, it doesn't come with the required libraries. We have two options here. Wither use Fedora gcc, or see if we can use APM drop gcc. First, we tried to use Fedora gcc as that MultiLib compiler. Unfortunately, building gcc using that Fedora compiler crashes with a message "C compiler cannot create executables". This problem is believed to occur if there are missing or corrupted libgcc, gcc-c++ and/or libstdc++ packages on the system. Reinstalling those packages on LEAP system didn't help.
We tried to use APM drop gcc, but it would crash pretty quickly as well, with the message "error: gmp.h header not found". Unfortunately, reinstalling gmp and gmp-devel packages did not solve this problem.
With the freshly installed Fedora 21, and fully installed gcc package from Fedora repos, we tried to build gcc again. This time it broke while trying to build "libgomp". Checking the build logs showed that the problem is: "/usr/bin/ld: cannot find -lgcc_s". The file "libgcc_s" is present in /usr/lib64/, which is the default. Somehow, the linker still doesn't find it. On the following screenshot, you can see the building error (left), the build log with the exact error (middle), and the corresponding code within the configure file (located at "rpmbuild/BUILD/gcc-4.9.2-20150212/libgomp/").
[[Image:Screenshot-from-2015-08-19-161047.png|thumb|px| ]]
The line that is failing the build is "3691: test $ac_status = 0; }; then :". The ac_status comes from "3688: (eval "$ac_link_default") 2>&5" and "3689: ac_status=$?". As you can see, $ac_link_default is giving 1 instead of 0. It gets its value from "3666: ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`". $ac_link is defined as "3323: ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'". It is believed that the value of $LDFLAGS is the problem. Possibly, it is overwriting the search path for the linker, resulting in the library not being found.
 
Next steps:
 
We need to put some echo statements in the mentioned above configure file to see if the guesses were correct. and LDFLAGS was the problem. If it was, we need to create a patch that would change the value of LDFLAGS to what we need, or, possibly, simply create a link in the correct place to the existing file. Then we will try to build our MultiLib capable gcc on that system. When succeeded, we will install our gcc on a LEAP builder, change the spec file for gcc to point towards that MultiLib capable gcc, and produce the final version of our gcc.
 
Testing ILP32:
 
* Create "hello.c" file.
* Add info to it at your discretion.
* Run "/opt/ilp32/usr/bin/gcc -c -mabi=ilp32 hello.c".
* Run "ld -m aarch64elf32 hello.o".
* If you want to run it in one commands, use "/opt/ilp32/usr/bin/gcc -mabi=ilp32 -Xlinker -maarch64elf32 hello.c".
* Run "file a.out".
* Check that it says "ELF32", "executable binary" and "statically linked".
 
 
 
 
 
Old information (outdated, kept here for reference/info):
GCC:
* I downloaded the source rpm from that build and manually downloaded and installed required dependencies from the same place.
* I run "rpm -i gcc-4.9.2-6.bb4.src.rpm" to install it on AArch64 builder.
* Due to internal RPM macros, I went had to change one of them in the "~/rpmbuild/SPEC" directory, and run command "rpmbuild -bp SPECS/gcc.spec" to get the prep stage . Information on the rpm.* I created a git repository (default macros can be found here: https://githubfedoraproject.comorg/ArtemLwiki/GCC), copied "~/rpmbuild/BUILD/gcc-4Packaging:RPMMacros.9.2-20150212/" directory into itTo fix the installation path, and pushed it.* I changed "~/git/GCC/gcc-4.9.2-20150212/configure" in added this line as the very first line of the next waysspec file:<pre>@@ -47,7 +47,7 @@ target=aarch64-unknown-linux-gnu  program_transform_name = s,y,y, -prefix = /usr/local+prefix = /opt/ilp32/usr/local exec_prefix = ${prefix}
srcdir = .</pre>* I committed the changes and run "git format-patch master --stdout > gcc49-makefile.patch" command to get the patch for my changes.* I copied "gcc49-makefile.patch" to "~%define _prefix /rpmbuildopt/SOURCESilp32/"I edited "~usr</rpmbuild/SPECS/gcc.spec" in the next way:pre>
* I run "export RPM_PACKAGER="Artem Luzyanin <artem.luzyanin@senecacollege.ca>""
* I run "rpmdev-bumpspec -c "This patch is Changed spec file to create ilp32-capable gcc in a separate tree."" command to add the changes with comments to the spec file.
* I run "rpmbuild -ba --nocheck gcc.spec" command to get the rpms.
* I run "rpm -qlp gcc-4.9.2-6.bb1.1.aarch64.rpmgcc.spec" command to check that all gcc files will be installed in the correct place(under /opt/ilp32/).
GLIBC:

Navigation menu