Skip to content

Commit

Permalink
fix C++ cross builds
Browse files Browse the repository at this point in the history
  • Loading branch information
nkraetzschmar committed Dec 12, 2023
1 parent 2757efb commit 42c3f59
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 10 additions & 1 deletion container/conf/setup_native
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion container/crossbuild.containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdio.h>\nint main() { printf("hello\\n"); return 0; }' > main.c \
&& gcc -o main main.c \
&& ./main \
&& printf '#include <iostream>\nint main() { std::cout << "hello" << std::endl; return 0; }' > main.cpp \
&& g++ -o main main.cpp \
&& ./main \
&& find /tmp -mindepth 1 -delete

Expand Down

0 comments on commit 42c3f59

Please sign in to comment.