Skip to content

Commit 50ae179

Browse files
committed
Merge branch 'fixup-raspbian-root'
2 parents 425941e + 917d4e0 commit 50ae179

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tools/meta/crosstool/crosstool.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package crosstool
55
import (
66
"fmt"
77
"io"
8+
"os"
89
"os/exec"
910
"path"
1011
"strings"
@@ -259,24 +260,52 @@ func installLibCXX(cpu CPU, sysroot string, opts Options, into *workspace.Worksp
259260
return project.Install(abiProject, into.Root)
260261
}
261262

263+
func fixupRaspbian(sys *workspace.Workspace) error {
264+
// The rapbian root we're using has an absolute symlink to libm.so. This
265+
// causes issues when we use libm, because lld will try to link against
266+
// libm.a instead which won't work, because we're doing a static build.
267+
// So, we need to fix the symlink.
268+
269+
// First delete the old symlink.
270+
if err := os.Remove(sys.Path("usr/lib/arm-linux-gnueabihf/libm.so")); err != nil {
271+
return err
272+
}
273+
274+
// Then setup the correct symlink.
275+
return os.Symlink(
276+
sys.Path("lib/arm-linux-gnueabihf/libm.so.6"),
277+
sys.Path("usr/lib/arm-linux-gnueabihf/libm.so"),
278+
)
279+
}
280+
262281
func fetchSysroot(cpu CPU) (*workspace.Workspace, error) {
263282
sys, err := workspace.New(workspace.NoCD)
264283
if err != nil {
265284
return nil, err
266285
}
267286

287+
var fixup func(*workspace.Workspace) error
288+
268289
var root fetch.RemoteArchive
269290
switch cpu {
270291
case CortexA53:
271292
root = ubuntuAArch64Root
272293
case CortexA7, ARM1176JZF_S:
273294
root = raspbianRoot
295+
fixup = fixupRaspbian
274296
}
275297

276298
if err := root.FetchTo(sys.Root); err != nil {
277299
sys.Cleanup()
278300
return nil, err
279301
}
302+
303+
if fixup != nil {
304+
if err := fixup(sys); err != nil {
305+
return nil, err
306+
}
307+
}
308+
280309
return sys, nil
281310
}
282311

0 commit comments

Comments
 (0)