Skip to content

Commit 0deebd9

Browse files
committed
refactor: Remove GCC references and update Clang wrapper for Vita libraries
1 parent 577ec60 commit 0deebd9

4 files changed

Lines changed: 91 additions & 198 deletions

File tree

CMakeLists.txt

Lines changed: 33 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ project(vitasdk)
1111
set(LLVM_VERSION 21.1.8)
1212
set(LLVM_HASH SHA256=4633a23617fa31a3ea51242586ea7fb1da7140e426bd62fc164261fe036aa142)
1313

14-
# Keep GCC version for reference (will be replaced by LLVM)
15-
set(GCC_VERSION 15.2.0)
16-
set(GCC_HASH SHA256=438fd996826b0c82485a29da03a72d71d6e3541a83ec702df4271f6fe025d24e)
17-
1814
set(ZLIB_VERSION 1.3.1)
1915
set(ZLIB_HASH SHA256=9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23)
2016

@@ -255,38 +251,6 @@ function(toolchain_deps toolchain_deps_dir toolchain_install_dir toolchain_suffi
255251
--disable-shared
256252
)
257253

258-
# MPC - Only needed for GCC (commented out for LLVM build)
259-
# ExternalProject_add(mpc${suffix}
260-
# DEPENDS gmp${suffix} mpfr${suffix}
261-
# URL https://ftp.gnu.org/gnu/mpc/mpc-${MPC_VERSION}.tar.gz
262-
# URL_HASH ${MPC_HASH}
263-
# DOWNLOAD_DIR ${DOWNLOAD_DIR}
264-
# CONFIGURE_COMMAND ${compiler_flags} ${wrapper_command} <SOURCE_DIR>/configure
265-
# --build=${build_native}
266-
# --host=${toolchain_host}
267-
# --prefix=${toolchain_deps_dir}
268-
# --libdir=${toolchain_deps_dir}/lib
269-
# --with-gmp=${toolchain_deps_dir}
270-
# --with-mpfr=${toolchain_deps_dir}
271-
# --disable-shared
272-
# --disable-nls
273-
# )
274-
275-
# ISL - Only needed for GCC (commented out for LLVM build)
276-
# ExternalProject_add(isl${suffix}
277-
# DEPENDS gmp${suffix}
278-
# GIT_REPOSITORY https://github.com/Meinersbur/isl
279-
# GIT_TAG isl-${ISL_VERSION}
280-
# DOWNLOAD_DIR ${DOWNLOAD_DIR}
281-
# CONFIGURE_COMMAND cd <SOURCE_DIR> && ./autogen.sh COMMAND ${compiler_flags} ${wrapper_command} <SOURCE_DIR>/configure
282-
# --build=${build_native}
283-
# --host=${toolchain_host}
284-
# --prefix=${toolchain_deps_dir}
285-
# --libdir=${toolchain_deps_dir}/lib
286-
# --with-gmp-prefix=${toolchain_deps_dir}
287-
# --disable-shared
288-
# ${UPDATE_DISCONNECTED_SUPPORT}
289-
# )
290254

291255
# Expat - Needed for GDB (XML parsing)
292256
ExternalProject_add(expat${suffix}
@@ -496,41 +460,6 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
496460
list(APPEND common_gcc_configure_args "--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm")
497461
endif()
498462

499-
# LLVM/Clang - Single build for cross-compilation
500-
# Unlike GCC, Clang doesn't need separate base/final builds
501-
# Build LLVM/Clang once and install directly to final location
502-
503-
# Build a basic gcc compiler, needed to compile newlib (COMMENTED OUT - Using LLVM instead)
504-
# ExternalProject_add(gcc-base
505-
# DEPENDS gmp_${build_suffix} mpfr_${build_suffix} mpc_${build_suffix} isl_${build_suffix} libelf_${build_suffix}
506-
# URL http://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz
507-
# URL_HASH ${GCC_HASH}
508-
# DOWNLOAD_DIR ${DOWNLOAD_DIR}
509-
# PATCH_COMMAND patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gcc/0001-gcc-15.patch
510-
# CONFIGURE_COMMAND ${compiler_flags} ${wrapper_command} <SOURCE_DIR>/configure
511-
# --build=${build_native}
512-
# # compile a native compiler so keep host == build
513-
# --host=${build_native}
514-
# --target=${target_arch}
515-
# --prefix=${toolchain_build_install_dir}
516-
# --libdir=${toolchain_build_install_dir}/lib
517-
# --libexecdir=${toolchain_build_install_dir}/lib
518-
# --with-sysroot=${toolchain_build_install_dir}/${target_arch}
519-
# --with-gmp=${toolchain_build_depends_dir}
520-
# --with-mpfr=${toolchain_build_depends_dir}
521-
# --with-mpc=${toolchain_build_depends_dir}
522-
# --with-isl=${toolchain_build_depends_dir}
523-
# --with-libelf=${toolchain_build_depends_dir}
524-
# ${common_gcc_configure_args}
525-
# --disable-threads
526-
# --without-headers
527-
# --disable-libgomp
528-
# "CFLAGS=${GCC_CFLAGS}"
529-
# "CXXFLAGS=${GCC_CFLAGS}"
530-
# BUILD_COMMAND $(MAKE) all-gcc
531-
# INSTALL_COMMAND $(MAKE) install-gcc
532-
# )
533-
534463
ExternalProject_add(vita-headers
535464
DEPENDS binutils_${build_suffix} vita-toolchain_${build_suffix}
536465
GIT_REPOSITORY https://github.com/vitasdk/vita-headers
@@ -607,9 +536,9 @@ ExternalProject_add(llvm
607536
# Create traditional tool names using the wrapper
608537
COMMAND ${CMAKE_COMMAND} -E create_symlink arm-vita-eabi-gcc-wrapper.sh ${CMAKE_INSTALL_PREFIX}/bin/${target_arch}-gcc
609538
COMMAND ${CMAKE_COMMAND} -E create_symlink arm-vita-eabi-gcc-wrapper.sh ${CMAKE_INSTALL_PREFIX}/bin/${target_arch}-cc
610-
# For C++, link directly to clang++ (no special libs needed)
611-
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_INSTALL_PREFIX}/bin/clang++ ${CMAKE_INSTALL_PREFIX}/bin/${target_arch}-g++
612-
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_INSTALL_PREFIX}/bin/clang++ ${CMAKE_INSTALL_PREFIX}/bin/${target_arch}-c++
539+
# For C++, also use the wrapper to ensure proper library linking
540+
COMMAND ${CMAKE_COMMAND} -E create_symlink arm-vita-eabi-gcc-wrapper.sh ${CMAKE_INSTALL_PREFIX}/bin/${target_arch}-g++
541+
COMMAND ${CMAKE_COMMAND} -E create_symlink arm-vita-eabi-gcc-wrapper.sh ${CMAKE_INSTALL_PREFIX}/bin/${target_arch}-c++
613542
# Remove docs to reduce size
614543
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_INSTALL_PREFIX}/share/man
615544
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_INSTALL_PREFIX}/share/info
@@ -621,9 +550,10 @@ ExternalProject_Add(newlib
621550
GIT_TAG ${NEWLIB_TAG}
622551
${GIT_SHALLOW_SUPPORT}
623552
PATCH_COMMAND patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/newlib-stdatomic-stdint.patch || true
553+
COMMAND patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/newlib-llvm-init-fini.patch || true
624554
# Pass the compiler_target_tools here so newlib picks up the fresh llvm-base compiler
625555
CONFIGURE_COMMAND ${compiler_flags} ${toolchain_tools} ${compiler_target_tools}
626-
${wrapper_command} <SOURCE_DIR>/configure "CFLAGS_FOR_TARGET=-g -O2 -ffunction-sections -fdata-sections -D_LDBL_EQ_DBL"
556+
${wrapper_command} <SOURCE_DIR>/configure "CFLAGS_FOR_TARGET=-g -O2 -ffunction-sections -fdata-sections -D_LDBL_EQ_DBL -D_HAVE_LONG_DOUBLE"
627557
--build=${build_native}
628558
--host=${host_native}
629559
--target=${target_arch}
@@ -645,47 +575,6 @@ ExternalProject_Add(newlib
645575
${UPDATE_DISCONNECTED_SUPPORT}
646576
)
647577

648-
# Build a complete gcc compiler to be able to compile the full gcc for the host when crosscompiling.
649-
# Using gcc-base doesn't work since is missing some headers.
650-
# (COMMENTED OUT - Using LLVM instead)
651-
# if(CMAKE_TOOLCHAIN_FILE)
652-
# ExternalProject_add(gcc-complete
653-
# DEPENDS newlib gmp_${build_suffix} mpfr_${build_suffix} mpc_${build_suffix} isl_${build_suffix} libelf_${build_suffix}
654-
# URL http://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz
655-
# URL_HASH ${GCC_HASH}
656-
# DOWNLOAD_DIR ${DOWNLOAD_DIR}
657-
# PATCH_COMMAND patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gcc/0001-gcc-15.patch
658-
# CONFIGURE_COMMAND ${compiler_flags} ${toolchain_tools}
659-
# ${wrapper_command} <SOURCE_DIR>/configure
660-
# --build=${build_native}
661-
# # compile a native compiler so keep host == build
662-
# --host=${build_native}
663-
# --target=${target_arch}
664-
# --prefix=${toolchain_build_install_dir}
665-
# --libdir=${toolchain_build_install_dir}/lib
666-
# --libexecdir=${toolchain_build_install_dir}/lib
667-
# --with-sysroot=${toolchain_build_install_dir}/${target_arch}
668-
# --with-gmp=${toolchain_build_depends_dir}
669-
# --with-mpfr=${toolchain_build_depends_dir}
670-
# --with-mpc=${toolchain_build_depends_dir}
671-
# --with-isl=${toolchain_build_depends_dir}
672-
# --with-libelf=${toolchain_build_depends_dir}
673-
# ${common_gcc_configure_args}
674-
# --enable-threads=posix
675-
# --with-headers=yes
676-
# --enable-libgomp
677-
# "CFLAGS=${GCC_CFLAGS}"
678-
# "CXXFLAGS=${GCC_CFLAGS}"
679-
# BUILD_COMMAND ${toolchain_tools} ${wrapper_command} $(MAKE) INHIBIT_LIBC_CFLAGS="-DUSE_TM_CLONE_REGISTRY=0"
680-
# INSTALL_COMMAND $(MAKE) install
681-
# )
682-
# # Add this target as dependency of the final gcc target
683-
# set(GCC_DEPENDS gcc-complete)
684-
# else()
685-
# # Just use gcc-base as the dependency of the final gcc target
686-
# set(GCC_DEPENDS gcc-base)
687-
# endif()
688-
689578
# LLVM doesn't need separate base/final builds like GCC did
690579
# Use llvm directly for all dependencies
691580

@@ -718,22 +607,23 @@ ExternalProject_add(llvm-runtimes
718607
SOURCE_SUBDIR runtimes
719608
CMAKE_ARGS
720609
-DCMAKE_BUILD_TYPE=Release
721-
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
610+
# Install C++ libraries directly in the sysroot so the linker can find them
611+
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/${target_arch}
722612
-DCMAKE_SYSTEM_NAME=Generic
723613
-DCMAKE_CROSSCOMPILING=ON
724614
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
725615
-DCMAKE_C_COMPILER=${CMAKE_INSTALL_PREFIX}/bin/clang
726616
-DCMAKE_CXX_COMPILER=${CMAKE_INSTALL_PREFIX}/bin/clang++
727617
-DCMAKE_AR=${binutils_prefix}-ar
728618
-DCMAKE_RANLIB=${binutils_prefix}-ranlib
729-
-DCMAKE_C_COMPILER_TARGET=${target_arch}
730-
-DCMAKE_CXX_COMPILER_TARGET=${target_arch}
731-
-DCMAKE_ASM_COMPILER_TARGET=${target_arch}
619+
-DCMAKE_C_COMPILER_TARGET=armv7-none-eabi
620+
-DCMAKE_CXX_COMPILER_TARGET=armv7-none-eabi
621+
-DCMAKE_ASM_COMPILER_TARGET=armv7-none-eabi
732622
-DCMAKE_SYSROOT=${CMAKE_INSTALL_PREFIX}/${target_arch}
733623
"-DCMAKE_C_FLAGS=--config ${CMAKE_INSTALL_PREFIX}/bin/arm-vita-eabi.cfg"
734-
"-DCMAKE_CXX_FLAGS=--config ${CMAKE_INSTALL_PREFIX}/bin/arm-vita-eabi.cfg"
624+
"-DCMAKE_CXX_FLAGS=--config ${CMAKE_INSTALL_PREFIX}/bin/arm-vita-eabi.cfg -D_LIBCPP_HAS_NO_STRTOLD -D_LIBUNWIND_IS_BAREMETAL -frtti -fexceptions"
735625
"-DCMAKE_ASM_FLAGS=--config ${CMAKE_INSTALL_PREFIX}/bin/arm-vita-eabi.cfg"
736-
-DLLVM_ENABLE_RUNTIMES=compiler-rt$<SEMICOLON>libcxx$<SEMICOLON>libcxxabi
626+
-DLLVM_ENABLE_RUNTIMES=compiler-rt$<SEMICOLON>libcxx$<SEMICOLON>libcxxabi$<SEMICOLON>libunwind
737627
# Compiler-RT configuration (libgcc equivalent)
738628
-DCOMPILER_RT_BUILD_BUILTINS=ON
739629
-DCOMPILER_RT_BUILD_SANITIZERS=OFF
@@ -743,6 +633,8 @@ ExternalProject_add(llvm-runtimes
743633
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
744634
-DCOMPILER_RT_BAREMETAL_BUILD=ON
745635
# libc++ configuration
636+
-DLIBCXX_ENABLE_NEWLIB=ON
637+
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON
746638
-DLIBCXX_HAS_PTHREAD_API=ON
747639
-DLIBCXX_ENABLE_SHARED=OFF
748640
-DLIBCXX_ENABLE_STATIC=ON
@@ -754,64 +646,33 @@ ExternalProject_add(llvm-runtimes
754646
-DLIBCXX_ENABLE_RANDOM_DEVICE=OFF
755647
-DLIBCXX_ENABLE_LOCALIZATION=OFF
756648
-DLIBCXX_PSTL_CPU_BACKEND=std_thread
649+
-DLIBCXX_HAS_NO_STRTOLD=ON
650+
-DLIBCXX_ENABLE_THREADS=ON
651+
-DLIBCXX_ENABLE_MONOTONIC_CLOCK=ON
757652
# libc++abi configuration
758-
-DLIBCXXABI_USE_LLVM_UNWINDER=OFF
653+
-DLIBCXXABI_USE_LLVM_UNWINDER=ON
759654
-DLIBCXXABI_ENABLE_SHARED=OFF
760655
-DLIBCXXABI_ENABLE_STATIC=ON
761656
-DLIBCXXABI_USE_COMPILER_RT=ON
762-
-DLIBCXXABI_USE_LLVM_UNWINDER=OFF
763657
-DLIBCXXABI_ENABLE_EXCEPTIONS=ON
764658
-DLIBCXXABI_ENABLE_ASSERTIONS=OFF
765659
-DLIBCXXABI_SILENT_TERMINATE=ON
660+
# libunwind configuration
661+
-DLIBUNWIND_ENABLE_SHARED=OFF
662+
-DLIBUNWIND_ENABLE_STATIC=ON
663+
-DLIBUNWIND_USE_COMPILER_RT=ON
664+
-DLIBUNWIND_ENABLE_CROSS_UNWINDING=OFF
766665
# Disable tests
767666
-DCOMPILER_RT_INCLUDE_TESTS=OFF
768667
-DLIBCXX_INCLUDE_TESTS=OFF
769668
-DLIBCXXABI_INCLUDE_TESTS=OFF
669+
-DLIBUNWIND_INCLUDE_TESTS=OFF
770670
BUILD_COMMAND $(MAKE)
771671
INSTALL_COMMAND $(MAKE) install
772672
)
773673

774674

775675

776-
# GCC-final commented out - using LLVM instead
777-
# ExternalProject_add(gcc-final
778-
# DEPENDS gmp_${target_suffix} mpfr_${target_suffix} mpc_${target_suffix} isl_${target_suffix} libelf_${target_suffix}
779-
# DEPENDS newlib ${GCC_DEPENDS} pthread-embedded
780-
# URL http://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz
781-
# URL_HASH ${GCC_HASH}
782-
# DOWNLOAD_DIR ${DOWNLOAD_DIR}
783-
# PATCH_COMMAND patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gcc/0001-gcc-15.patch
784-
# CONFIGURE_COMMAND ${compiler_flags} ${toolchain_tools} ${compiler_target_tools}
785-
# ${wrapper_command} <SOURCE_DIR>/configure
786-
# --build=${build_native}
787-
# --host=${host_native}
788-
# --target=${target_arch}
789-
# --prefix=${CMAKE_INSTALL_PREFIX}
790-
# --libdir=${CMAKE_INSTALL_PREFIX}/lib
791-
# --libexecdir=${CMAKE_INSTALL_PREFIX}/lib
792-
# --with-sysroot=${CMAKE_INSTALL_PREFIX}/${target_arch}
793-
# --with-gmp=${toolchain_target_depends_dir}
794-
# --with-mpfr=${toolchain_target_depends_dir}
795-
# --with-mpc=${toolchain_target_depends_dir}
796-
# --with-isl=${toolchain_target_depends_dir}
797-
# --with-libelf=${toolchain_target_depends_dir}
798-
# ${common_gcc_configure_args}
799-
# --with-headers=yes
800-
# --enable-threads=posix
801-
# --enable-libgomp
802-
# "CFLAGS=${GCC_CFLAGS}"
803-
# "CXXFLAGS=${GCC_CFLAGS}"
804-
# BUILD_COMMAND ${toolchain_tools} ${compiler_target_tools} ${wrapper_command}
805-
# $(MAKE) INHIBIT_LIBC_CFLAGS="-DUSE_TM_CLONE_REGISTRY=0"
806-
# INSTALL_COMMAND $(MAKE) install
807-
# # Remove gcc docs to reduce size
808-
# COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_INSTALL_PREFIX}/share/man
809-
# COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_INSTALL_PREFIX}/share/info
810-
# # Remove .la files
811-
# COMMAND ${CMAKE_COMMAND} -DGLOB_PATTERN=${CMAKE_INSTALL_PREFIX}/*.la
812-
# -P ${CMAKE_SOURCE_DIR}/cmake/remove_files.cmake
813-
# )
814-
815676
ExternalProject_Add(samples
816677
GIT_REPOSITORY https://github.com/vitasdk/samples
817678
GIT_TAG ${SAMPLES_TAG}
@@ -855,16 +716,15 @@ ExternalProject_Add(vita-makepkg
855716
${UPDATE_DISCONNECTED_SUPPORT}
856717
)
857718

858-
# Windows pthread DLL not needed for LLVM
859-
# if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
860-
# getgcclib(libwinpthread-1.dll WINPTHREAD_DLL)
861-
# if(WINPTHREAD_DLL)
862-
# add_custom_command(TARGET llvm-final POST_BUILD
863-
# COMMAND ${CMAKE_COMMAND} -E copy ${WINPTHREAD_DLL} ${CMAKE_INSTALL_PREFIX}/bin/
864-
# COMMENT "Copying libwinpthread-1.dll"
865-
# )
866-
# endif(WINPTHREAD_DLL)
867-
# endif()
719+
# Symlink armv7-none-eabi to arm-vita-unknown-eabi for LLVM runtimes
720+
add_custom_command(TARGET llvm-runtimes POST_BUILD
721+
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_INSTALL_PREFIX}/lib/clang/21/lib/arm-vita-unknown-eabi
722+
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_INSTALL_PREFIX}/lib/generic/libclang_rt.builtins-armv7.a ${CMAKE_INSTALL_PREFIX}/lib/clang/21/lib/arm-vita-unknown-eabi/libclang_rt.builtins.a
723+
# Create dummy crtbegin.o/crtend.o if missing, to satisfy clang driver
724+
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_INSTALL_PREFIX}/lib/clang/21/lib/arm-vita-unknown-eabi/clang_rt.crtbegin.o
725+
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_INSTALL_PREFIX}/lib/clang/21/lib/arm-vita-unknown-eabi/clang_rt.crtend.o
726+
COMMENT "Symlinking LLVM runtimes"
727+
)
868728

869729
# Strip toolchain binaries to reduce filesize
870730
add_custom_command(TARGET llvm-runtimes POST_BUILD

arm-vita-eabi-gcc-wrapper.sh

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
77

88
# Determine if we are running as C++ compiler
99
NAME=$(basename "$0")
10+
IS_CXX=0
1011
case "$NAME" in
1112
*g++*|*c++*)
12-
CLANG="${SCRIPT_DIR}/../arm-vita-eabi/bin/clang++"
13+
CLANG="${SCRIPT_DIR}/clang++"
14+
IS_CXX=1
1315
;;
1416
*)
15-
CLANG="${SCRIPT_DIR}/../arm-vita-eabi/bin/clang"
17+
CLANG="${SCRIPT_DIR}/clang"
1618
;;
1719
esac
1820

@@ -21,31 +23,44 @@ VITA_LIBS="-lSceRtc_stub -lSceSysmem_stub -lSceKernelThreadMgr_stub -lSceKernelM
2123

2224
# Check if we're linking (not just compiling)
2325
LINKING=1
26+
SHARED=0
2427
for arg in "$@"; do
2528
case "$arg" in
2629
-c|-E|-S)
2730
LINKING=0
28-
break
31+
;;
32+
-shared)
33+
SHARED=1
2934
;;
3035
esac
3136
done
3237

3338
# Execute clang with config file
3439
if [ $LINKING -eq 1 ]; then
35-
# Add Vita libraries when linking
36-
# Check if -pthread is in arguments
37-
PTHREAD_LIBS=""
38-
for arg in "$@"; do
39-
case "$arg" in
40-
-pthread|--pthread)
41-
PTHREAD_LIBS="--whole-archive -lpthread --no-whole-archive"
42-
break
43-
;;
44-
esac
45-
done
40+
# When linking, add all necessary libraries
41+
# Always include pthread (newlib requires it)
42+
# Use -Wl,--whole-archive for pthread to ensure all symbols are available
4643

47-
exec "${CLANG}" --config "${SCRIPT_DIR}/arm-vita-eabi.cfg" "$@" ${PTHREAD_LIBS} ${VITA_LIBS}
44+
if [ $SHARED -eq 0 ]; then
45+
# For executables, include standard libraries and Vita stubs
46+
if [ $IS_CXX -eq 1 ]; then
47+
# C++ executables need libc++ or libstdc++
48+
# Clang will automatically add -lc++ but we need to ensure proper order
49+
exec "${CLANG}" --config "${SCRIPT_DIR}/arm-vita-eabi.cfg" "$@" \
50+
-Wl,--whole-archive -lpthread -Wl,--no-whole-archive \
51+
-lc -lgloss -lm ${VITA_LIBS}
52+
else
53+
# C executables
54+
exec "${CLANG}" --config "${SCRIPT_DIR}/arm-vita-eabi.cfg" "$@" \
55+
-Wl,--whole-archive -lpthread -Wl,--no-whole-archive \
56+
-lc -lgloss -lm ${VITA_LIBS}
57+
fi
58+
else
59+
# For shared libraries, minimal linking
60+
exec "${CLANG}" --config "${SCRIPT_DIR}/arm-vita-eabi.cfg" "$@"
61+
fi
4862
else
4963
# Just compile, no libraries needed
64+
# Config must be first so architecture flags are applied
5065
exec "${CLANG}" --config "${SCRIPT_DIR}/arm-vita-eabi.cfg" "$@"
5166
fi

0 commit comments

Comments
 (0)