mirror of
https://github.com/SerenityOS/serenity
synced 2026-04-25 17:15:42 +02:00
Toolchain/GCC+LibC: Stop linking against crt0_shared
This makes GCC and Clang equal on that side and thus allows us to get rid of most GCC-only branches in LibC/CMakeLists.txt.
This commit is contained in:
committed by
Sönke Holz
parent
b140d3af2f
commit
45232a0f16
@@ -100,7 +100,7 @@ index 0000000000000000000000000000000000000000..53a4b8e93b74b4808a4bfed91c4d5558
|
||||
+#define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
|
||||
diff --git a/gcc/config/serenity.h b/gcc/config/serenity.h
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..effbe4bfb4c35db4785491e1628e6af9c0c87bf0
|
||||
index 0000000000000000000000000000000000000000..5b6c764c9bbf68fcf307aa67a19f6fc4305f74ef
|
||||
--- /dev/null
|
||||
+++ b/gcc/config/serenity.h
|
||||
@@ -0,0 +1,50 @@
|
||||
@@ -120,7 +120,7 @@ index 0000000000000000000000000000000000000000..effbe4bfb4c35db4785491e1628e6af9
|
||||
+/* Files that are linked before user code.
|
||||
+ The %s tells GCC to look for these files in the library directory. */
|
||||
+#undef STARTFILE_SPEC
|
||||
+#define STARTFILE_SPEC "%{!shared:crt0.o%s} %{shared: %{!fbuilding-libgcc:crt0_shared.o%s}} %{shared|static-pie|!no-pie:crtbeginS.o%s; :crtbegin.o%s}"
|
||||
+#define STARTFILE_SPEC "%{!shared:crt0.o%s} %{shared|static-pie|!no-pie:crtbeginS.o%s; :crtbegin.o%s}"
|
||||
+
|
||||
+/* Files that are linked after user code. */
|
||||
+#undef ENDFILE_SPEC
|
||||
|
||||
@@ -103,17 +103,6 @@ add_custom_command(
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy $<TARGET_OBJECTS:crt0> ${CMAKE_INSTALL_PREFIX}/usr/lib/crt0.o
|
||||
)
|
||||
|
||||
# FIXME: These files are never needed (and Clang driver never references them) but GCC might need
|
||||
# some convincing that this is the case.
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
add_library(crt0_shared STATIC crt0_shared.cpp)
|
||||
target_link_libraries(crt0_shared PRIVATE NoCoverage)
|
||||
add_custom_command(
|
||||
TARGET crt0_shared POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy $<TARGET_OBJECTS:crt0_shared> ${CMAKE_INSTALL_PREFIX}/usr/lib/crt0_shared.o
|
||||
)
|
||||
endif()
|
||||
|
||||
# ===== LibC =====
|
||||
# Prevent GCC from removing null checks by marking the `FILE*` argument non-null
|
||||
set_source_files_properties(stdio.cpp PROPERTIES COMPILE_FLAGS "-fno-builtin-fputc -fno-builtin-fputs -fno-builtin-fwrite")
|
||||
@@ -127,9 +116,6 @@ endif()
|
||||
|
||||
serenity_libc(LibC c)
|
||||
add_dependencies(LibC crt0 LibUBSanitizer)
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
add_dependencies(LibC crt0_shared)
|
||||
endif()
|
||||
target_link_libraries(LibC PRIVATE LibSystem LibTimeZone)
|
||||
target_link_options(LibC PRIVATE -nolibc)
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/Types.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/internals.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef _DYNAMIC_LOADER
|
||||
void* __dso_handle __attribute__((__weak__));
|
||||
#endif
|
||||
Reference in New Issue
Block a user