Re: [PATCH] go: Always pass interpreter to linker


Khem Raj
 

On Mon, Apr 11, 2022 at 6:30 AM Jose Quaresma <quaresma.jose@...> wrote:



J?rg Vehlow <lkml@...> escreveu no dia segunda, 11/04/2022 à(s) 13:35:

From: Joerg Vehlow <joerg.vehlow@...>

When gos internal linker is used, it uses hardcoded paths to the
interpreter (dynamic linker). For x86_64 this hardcoded path is
/lib64/ld-linux-x86-64.so.2, but yocto's default dynamic linker path
is /lib64/ld-linux-x86-64.so.2.

Is this correct? The first path is the seme one of the second.
its a typo, Sadly we do differ in baselib naming convention on x86_64
( without multilib )
compared to other distributions which are inherently multilib and use
/lib64 OE instead uses
/lib when multilib is not enabled but lib64/ when multilib is enabled.


Jose


Most of the time, the internal linker is not used and binutils linker
sets the correct path, but sometimes the internal linker is used and
the resulting binary will not work on x86_64.

To ensure the path is always correct, pass it to the linker.

Signed-off-by: Joerg Vehlow <joerg.vehlow@...>
---
meta/classes/go.bbclass | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass
index 9c4c92bffd..df8d4db26d 100644
--- a/meta/classes/go.bbclass
+++ b/meta/classes/go.bbclass
@@ -1,4 +1,5 @@
inherit goarch
+inherit linuxloader

GO_PARALLEL_BUILD ?= "${@oe.utils.parallel_make_argument(d, '-p %d')}"

@@ -44,7 +45,7 @@ GO_LINKMODE ?= ""
GO_LINKMODE:class-nativesdk = "--linkmode=external"
GO_LINKMODE:class-native = "--linkmode=external"
GO_EXTRA_LDFLAGS ?= ""
-GO_LDFLAGS ?= '-ldflags="${GO_RPATH} ${GO_LINKMODE} ${GO_EXTRA_LDFLAGS} -extldflags '${GO_EXTLDFLAGS}'"'
+GO_LDFLAGS ?= '-ldflags="${GO_RPATH} ${GO_LINKMODE} -I ${@get_linuxloader(d)} ${GO_EXTRA_LDFLAGS} -extldflags '${GO_EXTLDFLAGS}'"'
export GOBUILDFLAGS ?= "-v ${GO_LDFLAGS} -trimpath"
export GOPATH_OMIT_IN_ACTIONID ?= "1"
export GOPTESTBUILDFLAGS ?= "${GOBUILDFLAGS} -c"
--
2.25.1




--
Best regards,

José Quaresma

Join openembedded-core@lists.openembedded.org to automatically receive all group messages.