You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I am not mistaken, if relocations happens during build process it means the library is being statically linked. Now the question is: why would anyone want to static link libdl? I believe this could be caused by another package somewhere in the dependency tree that added -static or equivalent in the LDFLAGS directive for cgo.
Adding -x and -work flags should give us enough info to understand if it's the case by grepping in the files and logs. I should be able to try it myself tomorrow.
Relocations happen for any symbol that is in a different object file. Even if that symbol is one that is dynamically linked it must be relocated to the GOT & POT at build time.
However, I think you might be correct that there is something causing it to try and be statically linked which isn't possible with purego. Please do let me know what you find!
I was able to confirm on Ubunutu arm64 that building with #cgo LDFLAGS: -static produces the same output that is displayed above. This would suggest that this isn't an issue with purego as there is no way to statically link with purego since it requires libdl.so. Someone could rewrite the entire dynamic linker in Go but that sounds like it's begging to break.
I was able to confirm on Ubunutu arm64 that building with #cgo LDFLAGS: -static produces the same output that is displayed above. This would suggest that this isn't an issue with purego as there is no way to statically link with purego since it requires libdl.so. Someone could rewrite the entire dynamic linker in Go but that sounds like it's begging to break.
I'm using wails to build the desktop app ,I need to investigate it, thanks for the heads up.
There is definitely something going on with the connection between having import "C" and import "github.com/seasonjs/stable-diffusion" because doing CGO_ENABLED=1 go build with the below code still produces the error. Is there another import "C" in stable-diffusion? I still don't think this is an issue fixable inside purego.
package main
import (
_ "github.com/seasonjs/stable-diffusion"
)
import"C"funcmain() {
}
It likely has to do with the fact that //go:cgo_import_dynamic is for internal linking while //go:cgo_import_static is for external linking. The former is what purego uses and the later can't be used outside the compiler. I just don't know why it worked before.
Activity
eliottness commentedon Jan 15, 2024
Hey @Cyberhan123 👋
Can you also provide the output of go env (feel free to redact any value that you don't feel comfortable sharing)?
Cyberhan123 commentedon Jan 15, 2024
In fact, there is in the log.
hajimehoshi commentedon Jan 15, 2024
DataDog/dd-trace-go#2504 (comment)
@TotallyGamerJet Do you have any insights?
TotallyGamerJet commentedon Jan 15, 2024
I do not. Seems very strange since no changes to the dynamic linking have been made in quite a while
TotallyGamerJet commentedon Jan 15, 2024
@Cyberhan123 does it work if you set CGO_ENABLED=0?
eliottness commentedon Jan 15, 2024
If I am not mistaken, if relocations happens during build process it means the library is being statically linked. Now the question is: why would anyone want to static link libdl? I believe this could be caused by another package somewhere in the dependency tree that added
-staticor equivalent in theLDFLAGSdirective for cgo.Adding
-xand-workflags should give us enough info to understand if it's the case by grepping in the files and logs. I should be able to try it myself tomorrow.TotallyGamerJet commentedon Jan 15, 2024
Relocations happen for any symbol that is in a different object file. Even if that symbol is one that is dynamically linked it must be relocated to the GOT & POT at build time.
However, I think you might be correct that there is something causing it to try and be statically linked which isn't possible with purego. Please do let me know what you find!
TotallyGamerJet commentedon Jan 16, 2024
I was able to confirm on Ubunutu arm64 that building with
#cgo LDFLAGS: -staticproduces the same output that is displayed above. This would suggest that this isn't an issue with purego as there is no way to statically link with purego since it requires libdl.so. Someone could rewrite the entire dynamic linker in Go but that sounds like it's begging to break.Cyberhan123 commentedon Jan 16, 2024
If it is pure go code, there is no problem,If cgo exists, the above error will be reported.
Cyberhan123 commentedon Jan 16, 2024
I'm using
wailsto build the desktop app ,I need to investigate it, thanks for the heads up.Cyberhan123 commentedon Jan 16, 2024
My code below also causes this problem:
TotallyGamerJet commentedon Jan 16, 2024
There is definitely something going on with the connection between having
import "C"andimport "github.com/seasonjs/stable-diffusion"because doingCGO_ENABLED=1 go buildwith the below code still produces the error. Is there anotherimport "C"in stable-diffusion? I still don't think this is an issue fixable inside purego.Cyberhan123 commentedon Jan 16, 2024
No cgo code is used in stable-diffusion
10 remaining items
Cyberhan123 commentedon Jan 17, 2024
Let me make a small attempt: @rsc
TotallyGamerJet commentedon Jan 17, 2024
It likely has to do with the fact that
//go:cgo_import_dynamicis for internal linking while//go:cgo_import_staticis for external linking. The former is what purego uses and the later can't be used outside the compiler. I just don't know why it worked before.Fix issue 189 (#197)
hajimehoshi commentedon Jan 17, 2024
I'll tag v0.5.2 and v0.6.0-alpha.4 a few days later, if we don't find any other issues.
Fix issue 189 (#197)
hajimehoshi commentedon Jan 17, 2024
Let me reopen this. We are not able to cherry-pick this to 0.5 yet.
Fix issue 189 (#197)
reland: Fix issue 189 (#197)
hajimehoshi commentedon Jan 18, 2024
Done
go.mod: upgrade purego v0.5.1 => upgrade purego v0.5.2 (#63)