Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit f75ad79

Browse files
committed
Separate LD_LIBRARY_PATH adder for /opt/intel
1 parent 2fe22d3 commit f75ad79

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

handlers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ func checkForLibrariesMissingError(filepath string, sketch *SketchStatus, status
393393
if strings.Contains(err, "error while loading shared libraries") {
394394
// download dependencies and retry
395395
// if the error persists, bail out
396+
addIntelLibrariesToLdPath()
396397
fmt.Println("Missing library!")
397398
library := extractLibrary(err)
398399
status.Info("/upload", "Downloading needed libraries")

main.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,7 @@ func (p program) run() {
139139
// This way any external library can be safely copied there and the sketch should run anyway
140140
os.Setenv("LD_LIBRARY_PATH", filepath.Join(sketchFolder, "lib")+":"+os.Getenv("LD_LIBRARY_PATH"))
141141

142-
_, err = os.Stat("/opt/intel")
143-
if err == nil {
144-
//scan /opt/intel searching for sdks
145-
var extraPaths []string
146-
filepath.Walk("/opt/intel", func(path string, f os.FileInfo, err error) error {
147-
if strings.Contains(f.Name(), ".so") {
148-
extraPaths = appendIfUnique(extraPaths, path)
149-
}
150-
return nil
151-
})
152-
os.Setenv("LD_LIBRARY_PATH", strings.Join(extraPaths, ":")+":"+os.Getenv("LD_LIBRARY_PATH"))
153-
}
142+
addIntelLibrariesToLdPath()
154143

155144
files, err := ioutil.ReadDir(sketchFolder)
156145

utils.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package main
2+
3+
import (
4+
"os"
5+
"path/filepath"
6+
"strings"
7+
)
8+
9+
func addIntelLibrariesToLdPath() {
10+
_, err := os.Stat("/opt/intel")
11+
if err == nil {
12+
//scan /opt/intel searching for sdks
13+
var extraPaths []string
14+
filepath.Walk("/opt/intel", func(path string, f os.FileInfo, err error) error {
15+
if strings.Contains(f.Name(), ".so") {
16+
extraPaths = appendIfUnique(extraPaths, filepath.Dir(path))
17+
}
18+
return nil
19+
})
20+
os.Setenv("LD_LIBRARY_PATH", strings.Join(extraPaths, ":")+":"+os.Getenv("LD_LIBRARY_PATH"))
21+
}
22+
}

0 commit comments

Comments
 (0)