浏览代码

Toolchain: Fix usage of libgcc_s & build PIE executables by default

We can now build the porst with the shared libraries toolchain.
Itamar 4 年之前
父节点
当前提交
758fc8c063
共有 4 个文件被更改,包括 5 次插入4 次删除
  1. 2 2
      CMakeLists.txt
  2. 1 1
      Ports/gcc/patches/gcc.patch
  3. 1 0
      Toolchain/BuildIt.sh
  4. 1 1
      Toolchain/Patches/gcc.patch

+ 2 - 2
CMakeLists.txt

@@ -233,8 +233,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os -g1 -fno-exceptions -fno-rtti -Wno-a
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffile-prefix-map=${CMAKE_SOURCE_DIR}=.")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffile-prefix-map=${CMAKE_SOURCE_DIR}=.")
 
 
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG -DSANITIZE_PTRS")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG -DSANITIZE_PTRS")
-set(CMAKE_CXX_FLAGS_STATIC ${CMAKE_CXX_FLAGS})
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostartfiles -lgcc_s -pie -fpic")
+set(CMAKE_CXX_FLAGS_STATIC "${CMAKE_CXX_FLAGS} -static")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostartfiles -pie -fpic")
  
  
 add_link_options(--sysroot ${CMAKE_BINARY_DIR}/Root)
 add_link_options(--sysroot ${CMAKE_BINARY_DIR}/Root)
 
 

+ 1 - 1
Ports/gcc/patches/gcc.patch

@@ -128,7 +128,7 @@ index 000000000..2692b8e57
 +#define ENDFILE_SPEC "%{shared|pie:crtendS.o%s; :crtend.o%s} crtn.o%s"
 +#define ENDFILE_SPEC "%{shared|pie:crtendS.o%s; :crtend.o%s} crtn.o%s"
 +
 +
 +#undef LINK_SPEC
 +#undef LINK_SPEC
-+#define LINK_SPEC "%{shared:-shared} %{static:-static} %{!shared: %{!static: %{rdynamic:-export-dynamic} -dynamic-linker /usr/lib/Loader.so}}"
++#define LINK_SPEC "%{shared:-shared} %{static:-static} %{!static: %{rdynamic:-export-dynamic} %{!fbuilding-libgcc:-lgcc_s -dynamic-linker /usr/lib/Loader.so}}"
 +
 +
 +/* Additional predefined macros. */
 +/* Additional predefined macros. */
 +#undef TARGET_OS_CPP_BUILTINS
 +#undef TARGET_OS_CPP_BUILTINS

+ 1 - 0
Toolchain/BuildIt.sh

@@ -224,6 +224,7 @@ pushd "$DIR/Build/"
                                             --with-newlib \
                                             --with-newlib \
                                             --enable-shared \
                                             --enable-shared \
                                             --enable-languages=c,c++ \
                                             --enable-languages=c,c++ \
+                                            --enable-default-pie \
                                             ${TRY_USE_LOCAL_TOOLCHAIN:+"--quiet"} || exit 1
                                             ${TRY_USE_LOCAL_TOOLCHAIN:+"--quiet"} || exit 1
 
 
         echo "XXX build gcc and libgcc"
         echo "XXX build gcc and libgcc"

+ 1 - 1
Toolchain/Patches/gcc.patch

@@ -128,7 +128,7 @@ index 000000000..2692b8e57
 +#define ENDFILE_SPEC "%{shared|pie:crtendS.o%s; :crtend.o%s} crtn.o%s"
 +#define ENDFILE_SPEC "%{shared|pie:crtendS.o%s; :crtend.o%s} crtn.o%s"
 +
 +
 +#undef LINK_SPEC
 +#undef LINK_SPEC
-+#define LINK_SPEC "%{shared:-shared} %{static:-static} %{!shared: %{!static: %{rdynamic:-export-dynamic} -dynamic-linker /usr/lib/Loader.so}}"
++#define LINK_SPEC "%{shared:-shared} %{static:-static} %{!static: %{rdynamic:-export-dynamic} %{!fbuilding-libgcc:-lgcc_s -dynamic-linker /usr/lib/Loader.so}}"
 +
 +
 +/* Additional predefined macros. */
 +/* Additional predefined macros. */
 +#undef TARGET_OS_CPP_BUILTINS
 +#undef TARGET_OS_CPP_BUILTINS