From cc5c1144a7f1529d5bda1193cd020e33cf538457 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Tue, 16 Sep 2025 16:40:45 +0800 Subject: [PATCH 1/3] internal/crosscompile:Oz optimize level for embed target --- internal/crosscompile/crosscompile.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/crosscompile/crosscompile.go b/internal/crosscompile/crosscompile.go index 16027822..a1bf5ee5 100644 --- a/internal/crosscompile/crosscompile.go +++ b/internal/crosscompile/crosscompile.go @@ -481,9 +481,8 @@ func UseTarget(targetName string) (export Export, err error) { envs := buildEnvMap(env.LLGoROOT()) // Convert LLVMTarget, CPU, Features to CCFLAGS/LDFLAGS - var ccflags []string var ldflags []string - + ccflags := []string{"-Oz"} cflags := []string{"-Wno-override-module", "-Qunused-arguments", "-Wno-unused-command-line-argument"} if config.LLVMTarget != "" { cflags = append(cflags, "--target="+config.LLVMTarget) From 8fa3819714e91ffbd414186bd1df616f53e076c4 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Thu, 18 Sep 2025 15:22:02 +0800 Subject: [PATCH 2/3] internal/crosscompile:ld -s for embed target --- internal/build/build.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/build/build.go b/internal/build/build.go index 93f581ac..10effdb1 100644 --- a/internal/build/build.go +++ b/internal/build/build.go @@ -834,6 +834,7 @@ func linkObjFiles(ctx *context, app string, objFiles, linkArgs []string, verbose } buildArgs := []string{"-o", app} + buildArgs = append(buildArgs, "-s") buildArgs = append(buildArgs, linkArgs...) // Add build mode specific linker arguments From bbcbddfcad0cea415a3a02bc8d5c0790e27a5824 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Thu, 18 Sep 2025 15:44:31 +0800 Subject: [PATCH 3/3] internal/crosscompile:ld -S to ensure emit-reloc correct --- internal/build/build.go | 1 - internal/crosscompile/crosscompile.go | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/build/build.go b/internal/build/build.go index 10effdb1..93f581ac 100644 --- a/internal/build/build.go +++ b/internal/build/build.go @@ -834,7 +834,6 @@ func linkObjFiles(ctx *context, app string, objFiles, linkArgs []string, verbose } buildArgs := []string{"-o", app} - buildArgs = append(buildArgs, "-s") buildArgs = append(buildArgs, linkArgs...) // Add build mode specific linker arguments diff --git a/internal/crosscompile/crosscompile.go b/internal/crosscompile/crosscompile.go index a1bf5ee5..5807259b 100644 --- a/internal/crosscompile/crosscompile.go +++ b/internal/crosscompile/crosscompile.go @@ -481,7 +481,7 @@ func UseTarget(targetName string) (export Export, err error) { envs := buildEnvMap(env.LLGoROOT()) // Convert LLVMTarget, CPU, Features to CCFLAGS/LDFLAGS - var ldflags []string + ldflags := []string{"-S"} ccflags := []string{"-Oz"} cflags := []string{"-Wno-override-module", "-Qunused-arguments", "-Wno-unused-command-line-argument"} if config.LLVMTarget != "" {