Build issue under ubuntu 22.04
Hi,
I've set up a docker container with ubuntu 22.04 on it, and I can't build the crosscompiler toolchain (when running ./build.sh).
This is most likely due to the gcc being a really recent one gcc version 11.2.0 (Ubuntu 11.2.0-19ubuntu1).
The error I'm getting is:
/bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../binutils-src/bfd -DBINDIR='"/workspace/cross/bin"' -I. -I../../binutils-src/bfd -I../../binutils-src/bfd/../include -DHAVE_i386_elf32_vec -DHAVE_i386_elks_vec -DHAVE_i386_msdos_vec -DHAVE_i386_aout_vec -DHAVE_elf32_le_vec -DHAVE_elf32_be_vec -DHAVE_plugin_vec -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Werror -I../../binutils-src/bfd/../zlib -g -O2 -MT plugin.lo -MD -MP -MF .deps/plugin.Tpo -c -o plugin.lo ../../binutils-src/bfd/plugin.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../binutils-src/bfd -DBINDIR=\"/workspace/cross/bin\" -I. -I../../binutils-src/bfd -I../../binutils-src/bfd/../include -DHAVE_i386_elf32_vec -DHAVE_i386_elks_vec -DHAVE_i386_msdos_vec -DHAVE_i386_aout_vec -DHAVE_elf32_le_vec -DHAVE_elf32_be_vec -DHAVE_plugin_vec -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Werror -I../../binutils-src/bfd/../zlib -g -O2 -MT plugin.lo -MD -MP -MF .deps/plugin.Tpo -c ../../binutils-src/bfd/plugin.c -o plugin.o
In function 'load_plugin',
inlined from 'bfd_plugin_object_p' at ../../binutils-src/bfd/plugin.c:424:53:
../../binutils-src/bfd/plugin.c:403:20: error: 'valid_plugin' may be used uninitialized [-Werror=maybe-uninitialized]
403 | has_plugin = valid_plugin;
| ~~~~~~~~~~~^~~~~~~~~~~~~~
../../binutils-src/bfd/plugin.c: In function 'bfd_plugin_object_p':
../../binutils-src/bfd/plugin.c:397:11: note: 'valid_plugin' declared here
397 | int valid_plugin;
| ^~~~~~~~~~~~
cc1: all warnings being treated as errors
To fix that particular problem I did something like:
- int valid_plugin;
+ int valid_plugin = 0;
Edit1: Another one:
g++ -DHAVE_CONFIG_H -I. -I../../binutils-src/gold -I../../binutils-src/gold -I../../binutils-src/gold/../include -I../../binutils-src/gold/../elfcpp -DLOCALEDIR="\"/workspace/cross/share/locale\"" -DBINDIR="\"/workspace/cross/bin\"" -DTOOLBINDIR="\"/workspace/cross/ia16-elf/bin\"" -DTOOLLIBDIR="\"/workspace/cross/ia16-elf/lib\"" -W -Wall -Wstack-usage=262144 -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -frandom-seed=main.o -I../../binutils-src/gold/../zlib -pthread -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o ../../binutils-src/gold/main.cc
../../binutils-src/gold/main.cc: In function 'int main(int, char**)':
../../binutils-src/gold/main.cc:301:35: error: 'mallinfo mallinfo()' is deprecated [-Werror=deprecated-declarations]
301 | struct mallinfo m = mallinfo();
| ~~~~~~~~^~
In file included from ../../binutils-src/gold/main.cc:35:
/usr/include/malloc.h:114:24: note: declared here
114 | extern struct mallinfo mallinfo (void) __THROW __MALLOC_DEPRECATED;
| ^~~~~~~~
Fix:
@@ -297,11 +297,16 @@
elapsed.sys / 1000, (elapsed.sys % 1000) * 1000,
elapsed.wall / 1000, (elapsed.wall % 1000) * 1000);
-#ifdef HAVE_MALLINFO
- struct mallinfo m = mallinfo();
+/* taken from https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1786/diffs */
+#if defined (HAVE_MALLINFO) || defined (HAVE_MALLINFO2)
+#ifdef HAVE_MALLINFO2
+ struct mallinfo2 m = mallinfo2 ();
+#else
+ struct mallinfo m= mallinfo ();
+#endif
fprintf(stderr, _("%s: total space allocated by malloc: %lld bytes\n"),
program_name, static_cast<long long>(m.arena));
-#endif
+#endif /* defined (HAVE_MALLINFO) || defined (HAVE_MALLINFO2) */
File_read::print_stats();
Archive::print_stats();
Lib_group::print_stats();
Also on the configure.ac:
-AC_CHECK_FUNCS(mallinfo posix_fallocate fallocate readv sysconf times mkdtemp)
+AC_CHECK_FUNCS(mallinfo mallinfo2 posix_fallocate fallocate readv sysconf times mkdtemp)
Which might have been treated as a warning in older gcc versions, but not on these.
Hello @cocus,
Was this the only error and did the build complete, or are there still more similar issues? ELKS is running an older commit of the toolchain, perhaps with some more detail we can have @tkchia comment on whether you should try a later version of the compiler or other sources to address this problem.
Thank you!
No, these were the two ones. After that, I was able to build (except the missing stubbed functions of basic) the current ELKS repo for my 8018x
I hit this issue too. Maybe worth patching the toolchain?
Hey @Jookia, if you apply the diffs on the files I've mentioned, does it works for you?
Yes.
On Tue, May 03, 2022 at 03:48:27PM -0700, Santiago Hormazabal wrote:
Hey @Jookia, if you apply the diffs on the files I've mentioned, does it works for you?
-- Reply to this email directly or view it on GitHub: https://github.com/jbruchon/elks/issues/1270#issuecomment-1116731807 You are receiving this because you were mentioned.
Message ID: @.***>
Maybe worth patching the toolchain?
The toolchain built under the cross/ directory is built from specific commits numbers from https://github.com/tkchia/gcc-ia16, specified in tools/Makefile. None of the source files under cross/ are git-tracked on this repo. Thus, patches and/or changes are made upstream, which after testing, are added back to ELKS with a tools/Makefile update commit.
@cocus, perhaps you should submit your diff on the gcc-ia16 site, to see whether this may have already been addressed over there.
@cocus, perhaps you should submit your diff on the gcc-ia16 site, to see whether this may have already been addressed over there.
I'll open an issue on @tkchia's project and let's see if it works or not