Dead strip on "strip unused"

This commit is contained in:
Christoffer Lerno
2023-05-30 15:30:14 +02:00
committed by Christoffer Lerno
parent 275e3c6a09
commit ea1a5435bb
3 changed files with 18 additions and 1 deletions

View File

@@ -8,6 +8,7 @@
- `$assert` now uses `$assert <expr> : <optional message>` - `$assert` now uses `$assert <expr> : <optional message>`
- `$error` is syntax sugar for `$assert false : "Some message"` - `$error` is syntax sugar for `$assert false : "Some message"`
- `$include`, `$echo` no longer has mandatory `()` around the arguments. - `$include`, `$echo` no longer has mandatory `()` around the arguments.
- Updated cpu arguments for x86
- Dropped support for LLVM 13-14. - Dropped support for LLVM 13-14.
- Updated grammar and lexer definition. - Updated grammar and lexer definition.
- Removal of `$elif`. - Removal of `$elif`.

View File

@@ -286,6 +286,11 @@ static void linker_setup_macos(const char ***args_ref, LinkerType linker_type)
} }
add_arg("-arch"); add_arg("-arch");
add_arg(arch_to_linker_arch(platform_target.arch)); add_arg(arch_to_linker_arch(platform_target.arch));
if (active_target.strip_unused && active_target.type == TARGET_TYPE_EXECUTABLE)
{
add_arg("-no_exported_symbols");
add_arg("-dead_strip");
}
// Skip if no libc. // Skip if no libc.
if (active_target.no_libc) return; if (active_target.no_libc) return;
@@ -386,6 +391,12 @@ static void linker_setup_linux(const char ***args_ref, LinkerType linker_type)
if (active_target.no_libc) return; if (active_target.no_libc) return;
const char *crt_begin_dir = find_linux_crt_begin(); const char *crt_begin_dir = find_linux_crt_begin();
const char *crt_dir = find_linux_crt(); const char *crt_dir = find_linux_crt();
if (active_target.strip_unused && active_target.type == TARGET_TYPE_EXECUTABLE)
{
add_arg("-dead_strip");
}
if (!crt_begin_dir || !crt_dir) if (!crt_begin_dir || !crt_dir)
{ {
error_exit("Failed to find the C runtime at link time."); error_exit("Failed to find the C runtime at link time.");
@@ -431,6 +442,11 @@ static void linker_setup_freebsd(const char ***args_ref, LinkerType linker_type)
{ {
error_exit("Failed to find the C runtime at link time."); error_exit("Failed to find the C runtime at link time.");
} }
if (active_target.strip_unused && active_target.type == TARGET_TYPE_EXECUTABLE)
{
add_arg("-dead_strip");
}
if (is_pie_pic(platform_target.reloc_model)) if (is_pie_pic(platform_target.reloc_model))
{ {
add_arg("-pie"); add_arg("-pie");

View File

@@ -1 +1 @@
#define COMPILER_VERSION "0.4.517" #define COMPILER_VERSION "0.4.518"