Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

objcopy: '...': No such file on injectPath #74

Open
mirusu400 opened this issue Apr 4, 2024 · 0 comments
Open

objcopy: '...': No such file on injectPath #74

mirusu400 opened this issue Apr 4, 2024 · 0 comments

Comments

@mirusu400
Copy link

mirusu400 commented Apr 4, 2024

Hi, I'm attempting to build ardupilot using gllvm, but it doesn't works well. Here are debug outputs first:

[  67/2871] Compiling libraries/AP_Baro/AP_Baro_MS5611.cpp
WARNING:Did not recognize the compiler flag: -cl-single-precision-constant
objcopy: 'AP_Baro_BMP280.o': No such file
WARNING:attachBitcodePathToObject: objcopy [--add-section .llvm_bc=/tmp/gllvm1039652140 AP_Baro_BMP280.o] failed because exit status 1

[  68/2871] Compiling libraries/AP_Baro/AP_Baro_BMP085.cpp
WARNING:Did not recognize the compiler flag: -cl-single-precision-constant
objcopy: 'AP_Baro_SPL06.o': No such file
WARNING:attachBitcodePathToObject: objcopy [--add-section .llvm_bc=/tmp/gllvm2567432848 AP_Baro_SPL06.o] failed because exit status 1


...

Here are some sample to raise this error

# (Clone ardupilot with --recursive-submodules first)
export CC=gclang
export CXX=gclang++
./waf configure --board=SITL --debug -g --check-verbose --disable-Werror
./waf configure --check-cxx-compiler=clang++ --check-c-compiler=clang --board=SITL --debug -g --check-verbose --disable-Werror

./waf

gllvm/shared/compiler.go

Lines 188 to 255 in 7bb6e19

func injectPath(extension, bcFile, objFile string) (success bool) {
success = false
// Store bitcode path to temp file
var absBcPath, _ = filepath.Abs(bcFile)
tmpContent := []byte(absBcPath + "\n")
tmpFile, err := os.CreateTemp("", "gllvm")
if err != nil {
LogError("attachBitcodePathToObject: %v\n", err)
return
}
defer CheckDefer(func() error { return os.Remove(tmpFile.Name()) })
if _, err := tmpFile.Write(tmpContent); err != nil {
LogError("attachBitcodePathToObject: %v\n", err)
return
}
if err := tmpFile.Close(); err != nil {
LogError("attachBitcodePathToObject: %v\n", err)
return
}
// Let's write the bitcode section
var attachCmd string
var attachCmdArgs []string
if runtime.GOOS == osDARWIN {
if len(LLVMLd) > 0 {
attachCmd = LLVMLd
} else {
attachCmd = "ld"
}
attachCmdArgs = []string{"-r", "-keep_private_externs", objFile, "-sectcreate", DarwinSegmentName, DarwinSectionName, tmpFile.Name(), "-o", objFile}
} else {
if len(LLVMObjcopy) > 0 {
attachCmd = LLVMObjcopy
} else {
attachCmd = "objcopy"
}
attachCmdArgs = []string{"--add-section", ELFSectionName + "=" + tmpFile.Name(), objFile}
}
// Run the attach command and ignore errors
_, nerr := execCmd(attachCmd, attachCmdArgs, "")
if nerr != nil {
LogWarning("attachBitcodePathToObject: %v %v failed because %v\n", attachCmd, attachCmdArgs, nerr)
return
}
// Copy bitcode file to store, if necessary
if bcStorePath := LLVMBitcodeStorePath; bcStorePath != "" {
destFilePath := path.Join(bcStorePath, getHashedPath(absBcPath))
in, _ := os.Open(absBcPath)
defer CheckDefer(func() error { return in.Close() })
out, _ := os.Create(destFilePath)
defer CheckDefer(func() error { return out.Close() })
_, err := io.Copy(out, in)
if err != nil {
LogWarning("Copying bc to bitcode archive %v failed because %v\n", destFilePath, err)
return
}
err = out.Sync()
if err != nil {
LogWarning("Syncing bitcode archive %v failed because %v\n", destFilePath, err)
return
}
}
success = true
return
}

In some quick debugging, I've found that objFile argument injectPath cannot recognize correct path, so it raise error.

Does the error appear only in this project? Is there a solution by specifying environmental variables?

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant