Skip to content

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

@mirusu400

Description

@mirusu400

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions