@@ -571,6 +571,8 @@ function(add_integration_test test_name)
571571 target_compile_options (${fq_build_target_name} PRIVATE
572572 ${compile_options} ${INTEGRATION_TEST_COMPILE_OPTIONS} )
573573
574+ set (compiler_runtime "" )
575+
574576 if (LIBC_TARGET_ARCHITECTURE_IS_AMDGPU)
575577 target_link_options (${fq_build_target_name} PRIVATE
576578 ${LIBC_COMPILE_OPTIONS_DEFAULT} ${INTEGRATION_TEST_COMPILE_OPTIONS}
@@ -599,17 +601,19 @@ function(add_integration_test test_name)
599601 set (link_options
600602 -nolibc
601603 -nostartfiles
602- -static
604+ -nostdlib
603605 ${LIBC_LINK_OPTIONS_DEFAULT}
604606 ${LIBC_TEST_LINK_OPTIONS_DEFAULT}
605607 )
606608 target_link_options (${fq_build_target_name} PRIVATE ${link_options} )
609+ list (APPEND compiler_runtime ${LIBGCC_S_LOCATION} )
607610 endif ()
608611 target_link_libraries (
609612 ${fq_build_target_name}
610- ${fq_target_name} .__libc__
611613 libc.startup.${LIBC_TARGET_OS} .crt1
612614 libc.test .IntegrationTest.test
615+ ${fq_target_name} .__libc__
616+ ${compiler_runtime}
613617 )
614618 add_dependencies (${fq_build_target_name}
615619 libc.test .IntegrationTest.test
@@ -770,6 +774,7 @@ function(add_libc_hermetic test_name)
770774 ${HERMETIC_TEST_COMPILE_OPTIONS} )
771775
772776 set (link_libraries "" )
777+ set (compiler_runtime "" )
773778 foreach (lib IN LISTS HERMETIC_TEST_LINK_LIBRARIES)
774779 if (TARGET ${lib} .hermetic)
775780 list (APPEND link_libraries ${lib} .hermetic)
@@ -807,20 +812,22 @@ function(add_libc_hermetic test_name)
807812 set (link_options
808813 -nolibc
809814 -nostartfiles
810- -static
815+ -nostdlib
811816 ${LIBC_LINK_OPTIONS_DEFAULT}
812817 ${LIBC_TEST_LINK_OPTIONS_DEFAULT}
813818 )
814819 target_link_options (${fq_build_target_name} PRIVATE ${link_options} )
815- list (APPEND link_libraries ${LIBGCC_S_LOCATION} )
820+ list (APPEND compiler_runtime ${LIBGCC_S_LOCATION} )
816821 endif ()
817822 target_link_libraries (
818823 ${fq_build_target_name}
819824 PRIVATE
820825 libc.startup.${LIBC_TARGET_OS} .crt1
821826 ${link_libraries}
822827 LibcHermeticTestSupport.hermetic
823- ${fq_target_name} .__libc__)
828+ ${fq_target_name} .__libc__
829+ ${compiler_runtime}
830+ )
824831 add_dependencies (${fq_build_target_name}
825832 LibcTest.hermetic
826833 libc.test .UnitTest.ErrnoSetterMatcher
0 commit comments