diff --git a/internal/build/build.go b/internal/build/build.go index 307e131f..0a698dc3 100644 --- a/internal/build/build.go +++ b/internal/build/build.go @@ -251,7 +251,7 @@ func Do(args []string, conf *Config) ([]Package, error) { os.Setenv("PATH", env.BinDir()+":"+os.Getenv("PATH")) // TODO(xsw): check windows output := conf.OutFile != "" - export, err := crosscompile.Use(conf.Goos, conf.Goarch, IsWasiThreadsEnabled(), IsRpathChangeEnabled()) + export, err := crosscompile.Use(conf.Goos, conf.Goarch, IsWasiThreadsEnabled()) check(err) ctx := &context{env: env, conf: cfg, progSSA: progSSA, prog: prog, dedup: dedup, patches: patches, built: make(map[string]none), initial: initial, mode: mode, @@ -568,35 +568,9 @@ func linkMainPkg(ctx *context, pkg *packages.Package, pkgs []*aPackage, global l llFiles = append(llFiles, export) } - // add rpath and find libs - exargs := make([]string, 0, ctx.nLibdir<<1) - libs := make([]string, 0, ctx.nLibdir*3) - if IsRpathChangeEnabled() { - for _, arg := range linkArgs { - if strings.HasPrefix(arg, "-L") { - exargs = append(exargs, "-rpath", arg[2:]) - } else if strings.HasPrefix(arg, "-l") { - libs = append(libs, arg[2:]) - } - } - } - linkArgs = append(linkArgs, exargs...) - err = compileAndLinkLLFiles(ctx, app, llFiles, linkArgs, verbose) check(err) - if IsRpathChangeEnabled() && ctx.buildConf.Goos == "darwin" { - dylibDeps := make([]string, 0, len(libs)) - for _, lib := range libs { - dylibDep := findDylibDep(app, lib) - if dylibDep != "" { - dylibDeps = append(dylibDeps, dylibDep) - } - } - err := ctx.env.InstallNameTool().ChangeToRpath(app, dylibDeps...) - check(err) - } - switch mode { case ModeTest: cmd := exec.Command(app, conf.RunArgs...) @@ -971,7 +945,6 @@ const llgoDbgSyms = "LLGO_DEBUG_SYMBOLS" const llgoTrace = "LLGO_TRACE" const llgoOptimize = "LLGO_OPTIMIZE" const llgoCheck = "LLGO_CHECK" -const llgoRpathChange = "LLGO_RPATH_CHANGE" const llgoWasmRuntime = "LLGO_WASM_RUNTIME" const llgoWasiThreads = "LLGO_WASI_THREADS" const llgoStdioNobuf = "LLGO_STDIO_NOBUF" @@ -1018,10 +991,6 @@ func IsCheckEnable() bool { return isEnvOn(llgoCheck, false) } -func IsRpathChangeEnabled() bool { - return isEnvOn(llgoRpathChange, false) -} - func IsWasiThreadsEnabled() bool { return isEnvOn(llgoWasiThreads, true) } diff --git a/internal/crosscompile/cosscompile.go b/internal/crosscompile/cosscompile.go index df6e4aaf..f066c8ac 100644 --- a/internal/crosscompile/cosscompile.go +++ b/internal/crosscompile/cosscompile.go @@ -25,7 +25,7 @@ func cacheDir() string { return filepath.Join(env.LLGoCacheDir(), "crosscompile") } -func Use(goos, goarch string, wasiThreads, changeRpath bool) (export Export, err error) { +func Use(goos, goarch string, wasiThreads bool) (export Export, err error) { targetTriple := llvm.GetTargetTriple(goos, goarch) if runtime.GOOS == goos && runtime.GOARCH == goarch { @@ -41,13 +41,6 @@ func Use(goos, goarch string, wasiThreads, changeRpath bool) (export Export, err // Add OS-specific flags switch goos { case "darwin": // ld64.lld (macOS) - if changeRpath { - export.LDFLAGS = append( - export.LDFLAGS, - "-rpath", "@loader_path", - "-rpath", "@loader_path/../lib", - ) - } export.LDFLAGS = append( export.LDFLAGS, "-Xlinker", "-dead_strip", diff --git a/internal/crosscompile/crosscompile_test.go b/internal/crosscompile/crosscompile_test.go index 6c062408..9ce9bbe9 100644 --- a/internal/crosscompile/crosscompile_test.go +++ b/internal/crosscompile/crosscompile_test.go @@ -75,7 +75,7 @@ func TestUseCrossCompileSDK(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - export, err := Use(tc.goos, tc.goarch, false, false) + export, err := Use(tc.goos, tc.goarch, false) if err != nil { t.Fatalf("Unexpected error: %v", err)