Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build error gcc13 clang 14 #3

Open
dokoma opened this issue Apr 18, 2024 · 1 comment
Open

build error gcc13 clang 14 #3

dokoma opened this issue Apr 18, 2024 · 1 comment

Comments

@dokoma
Copy link

dokoma commented Apr 18, 2024

Hello, Johnny! it's me again ,
last time I followed your instruction #2 and upgrade the gcc to higher version.
I still can not make it work, post them bellow.
or would you like to tell me your environment/version that would work?

I really appreciate your patience and help!

#g++ --version
g++ (Debian 13.2.0-13) 13.2.0
clang14

root@457ba67e0ebc:/# uname -a
Linux 457ba67e0ebc 6.6.16-linuxkit #1 SMP PREEMPT_DYNAMIC Fri Feb 16 11:55:08 UTC 2024 aarch64 GNU/Linux

I compile it with this and got error , I tried change the code and add link the -lc, and change the order.

root@ee19b7088f10:~/workspace/gmloader-next# make -f Makefile.gmloader ARCH=aarch64-linux-gnu LLVM_FILE=/usr/lib/llvm-14/lib/libclang-14.so.1
g++ -L3rdparty/libbsd/src/.libs -L/lib/aarch64-linux-gnu -Os  -o build/aarch64-linux-gnu/gmloader/gmloader build/aarch64-linux-gnu/loader/io_util.cpp.o build/aarch64-linux-gnu/loader/so_util.cpp.o build/aarch64-linux-gnu/loader/so_util_arm32.cpp.o build/aarch64-linux-gnu/loader/so_util_arm64.cpp.o build/aarch64-linux-gnu/thunks/khronos/egl.cpp.o build/aarch64-linux-gnu/thunks/khronos/gles2.cpp.o build/aarch64-linux-gnu/thunks/libc/aeabi.cpp.o build/aarch64-linux-gnu/thunks/libc/ctype.cpp.o build/aarch64-linux-gnu/thunks/libc/fortify.cpp.o build/aarch64-linux-gnu/thunks/libc/legacy.cpp.o build/aarch64-linux-gnu/thunks/libc/libc_table.cpp.o build/aarch64-linux-gnu/thunks/libc/misc.cpp.o build/aarch64-linux-gnu/thunks/libc/pthread.cpp.o build/aarch64-linux-gnu/thunks/libc/stdio.cpp.o build/aarch64-linux-gnu/thunks/libc/time64.cpp.o build/aarch64-linux-gnu/thunks/openal/openal.cpp.o build/aarch64-linux-gnu/thunks/zlib/zlib.cpp.o build/aarch64-linux-gnu/jni/classes/os_Build.cpp.o build/aarch64-linux-gnu/jni/classes/string.cpp.o build/aarch64-linux-gnu/jni/class_registry.cpp.o build/aarch64-linux-gnu/jni/jni.cpp.o build/aarch64-linux-gnu/gmloader/gamepad.cpp.o build/aarch64-linux-gnu/gmloader/input.cpp.o build/aarch64-linux-gnu/gmloader/libyoyo.cpp.o build/aarch64-linux-gnu/gmloader/main.cpp.o build/aarch64-linux-gnu/gmloader/mouse.cpp.o build/aarch64-linux-gnu/gmloader/classes/RunnerJNILib.cpp.o ./build/aarch64-linux-gnu/libbsd/fpurge.c.o ./build/aarch64-linux-gnu/libbsd/strtonum.c.o ./build/aarch64-linux-gnu/libbsd/strlcpy.c.o ./build/aarch64-linux-gnu/libbsd/setmode.c.o ./build/aarch64-linux-gnu/libbsd/progname.c.o ./build/aarch64-linux-gnu/libbsd/timeconv.c.o ./build/aarch64-linux-gnu/libbsd/radixsort.c.o ./build/aarch64-linux-gnu/libbsd/arc4random.c.o ./build/aarch64-linux-gnu/libbsd/wcslcpy.c.o ./build/aarch64-linux-gnu/libbsd/reallocf.c.o ./build/aarch64-linux-gnu/libbsd/humanize_number.c.o ./build/aarch64-linux-gnu/libbsd/fgetln.c.o ./build/aarch64-linux-gnu/libbsd/strtoi.c.o ./build/aarch64-linux-gnu/libbsd/funopen.c.o ./build/aarch64-linux-gnu/libbsd/flopen.c.o ./build/aarch64-linux-gnu/libbsd/freezero.c.o ./build/aarch64-linux-gnu/libbsd/setproctitle.c.o ./build/aarch64-linux-gnu/libbsd/fparseln.c.o ./build/aarch64-linux-gnu/libbsd/getpeereid.c.o ./build/aarch64-linux-gnu/libbsd/setproctitle_ctor.c.o ./build/aarch64-linux-gnu/libbsd/fmtcheck.c.o ./build/aarch64-linux-gnu/libbsd/dehumanize_number.c.o ./build/aarch64-linux-gnu/libbsd/fgetwln.c.o ./build/aarch64-linux-gnu/libbsd/recallocarray.c.o ./build/aarch64-linux-gnu/libbsd/strnstr.c.o ./build/aarch64-linux-gnu/libbsd/pwcache.c.o ./build/aarch64-linux-gnu/libbsd/strmode.c.o ./build/aarch64-linux-gnu/libbsd/explicit_bzero.c.o ./build/aarch64-linux-gnu/libbsd/wcslcat.c.o ./build/aarch64-linux-gnu/libbsd/readpassphrase.c.o ./build/aarch64-linux-gnu/libbsd/vis.c.o ./build/aarch64-linux-gnu/libbsd/unvis.c.o ./build/aarch64-linux-gnu/libbsd/merge.c.o ./build/aarch64-linux-gnu/libbsd/err.c.o ./build/aarch64-linux-gnu/libbsd/expand_number.c.o ./build/aarch64-linux-gnu/libbsd/closefrom.c.o ./build/aarch64-linux-gnu/libbsd/nlist.c.o ./build/aarch64-linux-gnu/libbsd/heapsort.c.o ./build/aarch64-linux-gnu/libbsd/pidfile.c.o ./build/aarch64-linux-gnu/libbsd/reallocarray.c.o ./build/aarch64-linux-gnu/libbsd/strtou.c.o ./build/aarch64-linux-gnu/libbsd/bsd_getopt.c.o ./build/aarch64-linux-gnu/libbsd/stringlist.c.o ./build/aarch64-linux-gnu/libbsd/strlcat.c.o ./build/aarch64-linux-gnu/libbsd/inet_net_pton.c.o ./build/aarch64-linux-gnu/libbsd/getbsize.c.o ./build/aarch64-linux-gnu/libbsd/arc4random_uniform.c.o ./build/aarch64-linux-gnu/libmd/md5.c.o -pthread -lm -lrt -lSDL2  -lopenal  -lz  -lzip  -lc
/usr/bin/ld: build/aarch64-linux-gnu/thunks/libc/stdio.cpp.o: in function `__vsprintf_chk_impl(char*, int, unsigned long, char const*, std::__va_list)':
stdio.cpp:(.text+0x4ec): undefined reference to `__vsprintf_chk(char*, int, unsigned long, char const*, std::__va_list)'
/usr/bin/ld: build/aarch64-linux-gnu/thunks/libc/libc_table.cpp.o:(.data.rel+0xbe8): undefined reference to `at_quick_exit'
/usr/bin/ld: build/aarch64-linux-gnu/thunks/libc/libc_table.cpp.o:(.data.rel+0xbf8): undefined reference to `atexit'
/usr/bin/ld: build/aarch64-linux-gnu/thunks/libc/libc_table.cpp.o:(.data.rel+0x2338): undefined reference to `pthread_atfork'
collect2: error: ld returned 1 exit status

The following is something I checked do not know if it might be useful .

I think it's there but mayby libc_hidden_proto? ref to : https://github.com/lattera/glibc/blob/master/include/stdio.h#L45

root@ee19b7088f10:~/workspace/gmloader-next# nm -D  /lib/aarch64-linux-gnu/libc.so.6 | grep  vsprintf 
000000000006e980 T _IO_vsprintf@@GLIBC_2.17
00000000000f92e0 T __vsprintf_chk@@GLIBC_2.17
000000000006e980 W vsprintf@@GLIBC_2.17

check the headers :

root@ee19b7088f10:~/workspace/gmloader-next# grep -R __vsprintf /usr/include
/usr/include/aarch64-linux-gnu/bits/stdio2-decl.h:extern int __vsprintf_chk (char *__restrict __s, int __flag, size_t __slen,
/usr/include/aarch64-linux-gnu/bits/stdio2.h:  return __builtin___vsprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,

check the refrence:

root@ee19b7088f10:~/workspace/gmloader-next# grep -R __vsprintf .
....
./build/aarch64-linux-gnu/thunks/libc/impl_header.h:extern ABI_ATTR int __vsprintf_chk_impl(char *, int, size_t, const char *, va_list);
./build/aarch64-linux-gnu/thunks/libc/impl_tab.h:NO_THUNK("__vsprintf_chk", (uintptr_t)&__vsprintf_chk_impl),
....
./thunks/libc/fortify.cpp:// Runtime implementation of __builtin____vsprintf_chk (used directly by compiler, not in headers).
./thunks/libc/fortify.cpp:extern "C" int ABI_ATTR __vsprintf_chk_impl(char* dst, int /*flags*/,
./thunks/libc/fortify.cpp:  int result = __vsprintf_chk_impl(dst, flags, dst_len_from_compiler, format, va);
./thunks/libc/stdio.cpp:extern int __vsprintf_chk(char *, int, size_t, const char *, va_list);
./thunks/libc/stdio.cpp:ABI_ATTR int __vsprintf_chk_impl(char * s, int flag, size_t slen, const char * format, va_list args)
./thunks/libc/stdio.cpp:    return __vsprintf_chk(s, flag, slen, format, args);
./thunks/libc/symtab:__vsprintf_chk

headers ,and no __vsprintf available

root@ee19b7088f10:~/workspace/gmloader-next# grep vsprintf /usr/include/*.h
/usr/include/stdio.h:extern int vsprintf (char *__restrict __s, const char *__restrict __format,
/usr/include/zlib.h:   zlib was compiled with the insecure functions sprintf() or vsprintf(),

here

root@ee19b7088f10:~/workspace/gmloader-next# grep -R __vsprintf /usr/include
/usr/include/aarch64-linux-gnu/bits/stdio2-decl.h:extern int __vsprintf_chk (char *__restrict __s, int __flag, size_t __slen,
/usr/include/aarch64-linux-gnu/bits/stdio2.h:  return __builtin___vsprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
@JohnnyonFlame
Copy link
Owner

JohnnyonFlame commented Apr 19, 2024

/usr/bin/ld: build/aarch64-linux-gnu/thunks/libc/libc_table.cpp.o:(.data.rel+0xbe8): undefined reference to `at_quick_exit'
/usr/bin/ld: build/aarch64-linux-gnu/thunks/libc/libc_table.cpp.o:(.data.rel+0xbf8): undefined reference to `atexit'
/usr/bin/ld: build/aarch64-linux-gnu/thunks/libc/libc_table.cpp.o:(.data.rel+0x2338): undefined reference to `pthread_atfork'

pthread_atfork can probably be defined as a _impl stub (search for the _impl functions on the libc thunks folder to see examples, anything with a _impl suffix in these is picked up and exported automatically). pthread_atfork and atexit however are odd, seems like something on your compiler is wrong? You can also export stubs for them with _impl since they shouldnt be too important here.

stdio.cpp:(.text+0x4ec): undefined reference to `__vsprintf_chk(char*, int, unsigned long, char const*, std::__va_list)'

Odd. You can just use standard vsprintf instead.

 or would you like to tell me your environment/version that would work?

I build using an Ubuntu 19.04 WSL2 instance with a few package backports (sdl2.18.x, cmake, etc) - I have yet to publish a guide on building these from scratch.

I really appreciate your patience and help!

I also appreciate the enthusiasm, hope we can get it to work for you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants