Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 1 addition & 32 deletions internal/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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...)
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down
9 changes: 1 addition & 8 deletions internal/crosscompile/cosscompile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion internal/crosscompile/crosscompile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading