From 42c3f596b3b3f1562e11a774bb2fd98cdb748de5 Mon Sep 17 00:00:00 2001 From: nkraetzschmar <9020053+nkraetzschmar@users.noreply.github.com> Date: Tue, 12 Dec 2023 16:42:16 +0100 Subject: [PATCH] fix C++ cross builds --- container/conf/setup_native | 11 ++++++++++- container/crossbuild.containerfile | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/container/conf/setup_native b/container/conf/setup_native index b2c621f..0dcc46e 100755 --- a/container/conf/setup_native +++ b/container/conf/setup_native @@ -37,7 +37,16 @@ function export_elf ( new_file="/native/$(basename "$file")" fi [ ! -e "$new_file" ] - bbe -e 's|/usr/lib/gcc-cross/|///////usr/lib/gcc/|;s|/usr/libexec/gcc-cross/|///////usr/libexec/gcc/|' < "$file" > "$new_file" + + cat < "$file" \ + | bbe -e 's|/usr/lib/gcc-cross/|///////usr/lib/gcc/|' \ + | bbe -e 's|/usr/libexec/gcc-cross/|///////usr/libexec/gcc/|' \ + | bbe -e 's|/x86_64-linux-gnu/include/c++/13/x86_64-linux-gnu|//////////////////include/x86_64-linux-gnu/c++/13|' \ + | bbe -e 's|/x86_64-linux-gnu/include/c++/|//////////////////include/c++/|' \ + | bbe -e 's|/aarch64-linux-gnu/include/c++/13/aarch64-linux-gnu|///////////////////include/aarch64-linux-gnu/c++/13|' \ + | bbe -e 's|/aarch64-linux-gnu/include/c++/|///////////////////include/c++/|' \ + > "$new_file" + if [ -x "$file" ]; then chmod +x "$new_file" fi diff --git a/container/crossbuild.containerfile b/container/crossbuild.containerfile index 21d3a95..73b6d0b 100644 --- a/container/crossbuild.containerfile +++ b/container/crossbuild.containerfile @@ -51,8 +51,11 @@ RUN [ "/native/bash", "-c", "PATH=/native:$PATH ./setup_native import $(awk '{ p # Run gcc test after setup_native and then clean up /tmp RUN gcc --print-search-dir \ - && echo 'int main() { return 0; }' > main.c \ + && printf '#include \nint main() { printf("hello\\n"); return 0; }' > main.c \ && gcc -o main main.c \ + && ./main \ + && printf '#include \nint main() { std::cout << "hello" << std::endl; return 0; }' > main.cpp \ + && g++ -o main main.cpp \ && ./main \ && find /tmp -mindepth 1 -delete