Re: [go-nuts] wrong ELF class error: How to compile 64 bit binary on Solaris 11 using gccgo
Thanks. I found that on Solaris 11 the 64 bit libs are generated under /usr/gnu/lib/64 when gcc was configured with --prefix= /usr/gnu. Everything works on Solaris 11. However, I am facing problems on Solaris 10 as it seems there are no 64-bit libs generated there. I will ask another question if I can't seem to find a way. Thanks so much for helping out on this. On Friday, September 28, 2018 at 6:17:39 PM UTC-7, Ian Lance Taylor wrote: > > On Fri, Sep 28, 2018 at 5:33 PM, > > wrote: > > Hi Ian, > >Setting GCCGO env variable helped. I basically compiled, > helloworld.go > > with the following options and it compiled a 64 bit exectable: > > > > CC=/home/amandeep/workspace/mygcc.sh > > GCCGO=/home/amandeep/workspace/mygccgo.sh CGO_CFLAGS='-m64' > > CGO_LDFLAGS='-m64' GOARCH=sparc64 CGO_ENABLED=1 go build > -gccgoflags=-m64 > > helloworld.go > > > > amandeep@s113ldom1:~/workspace$ file helloworld > > helloworld: ELF 64-bit MSB executable SPARCV9 Version 1, > > dynamically linked, not stripped > > > > However, I still can't run the executable: > > amandeep@s113ldom1:~/workspace$ ./helloworld > > ld.so.1: helloworld: fatal: /usr/gnu/lib/libgo.so.13: wrong ELF class: > > ELFCLASS32 > > Killed > > > > Does it mean that I need to compile gcc from source again with 64-bit > hack > > i.e. by running gcc configure with CC=/path/to/mygcc and recompile it? > > You'll need to set LD_LIBRARY_PATH to point to the directory with your > 64-bit libgo.so. > > > > When I said "a 32 bit archive" I meant the .a on which output of file > > command looks like the following: > > amandeep@s113ldom1:~/workspace$ file > > /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a > > /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a: > > current ar archive, 32-bit symbol table > > > > I assumed that the error wrong ELF class: ELFCLASS32 was related to the > > archive created with incorrect compiler options. > > Pedantically speaking, this is about the objects in the archive, not > the archive itself. > > Ian > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] wrong ELF class error: How to compile 64 bit binary on Solaris 11 using gccgo
On Fri, Sep 28, 2018 at 5:33 PM, wrote: > Hi Ian, >Setting GCCGO env variable helped. I basically compiled, helloworld.go > with the following options and it compiled a 64 bit exectable: > > CC=/home/amandeep/workspace/mygcc.sh > GCCGO=/home/amandeep/workspace/mygccgo.sh CGO_CFLAGS='-m64' > CGO_LDFLAGS='-m64' GOARCH=sparc64 CGO_ENABLED=1 go build -gccgoflags=-m64 > helloworld.go > > amandeep@s113ldom1:~/workspace$ file helloworld > helloworld: ELF 64-bit MSB executable SPARCV9 Version 1, > dynamically linked, not stripped > > However, I still can't run the executable: > amandeep@s113ldom1:~/workspace$ ./helloworld > ld.so.1: helloworld: fatal: /usr/gnu/lib/libgo.so.13: wrong ELF class: > ELFCLASS32 > Killed > > Does it mean that I need to compile gcc from source again with 64-bit hack > i.e. by running gcc configure with CC=/path/to/mygcc and recompile it? You'll need to set LD_LIBRARY_PATH to point to the directory with your 64-bit libgo.so. > When I said "a 32 bit archive" I meant the .a on which output of file > command looks like the following: > amandeep@s113ldom1:~/workspace$ file > /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a > /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a: > current ar archive, 32-bit symbol table > > I assumed that the error wrong ELF class: ELFCLASS32 was related to the > archive created with incorrect compiler options. Pedantically speaking, this is about the objects in the archive, not the archive itself. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] wrong ELF class error: How to compile 64 bit binary on Solaris 11 using gccgo
Hi Ian, Setting GCCGO env variable helped. I basically compiled, helloworld.go with the following options and it compiled a 64 bit exectable: CC=/home/amandeep/workspace/mygcc.sh GCCGO=/home/amandeep/workspace/mygccgo.sh CGO_CFLAGS='-m64' CGO_LDFLAGS='-m64' GOARCH=sparc64 CGO_ENABLED=1 go build -gccgoflags=-m64 helloworld.go amandeep@s113ldom1:~/workspace$ file helloworld helloworld: ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped However, I still can't run the executable: amandeep@s113ldom1:~/workspace$ ./helloworld ld.so.1: helloworld: fatal: /usr/gnu/lib/libgo.so.13: wrong ELF class: ELFCLASS32 Killed Does it mean that I need to compile gcc from source again with 64-bit hack i.e. by running gcc configure with CC=/path/to/mygcc and recompile it? When I said "a 32 bit archive" I meant the .a on which output of file command looks like the following: amandeep@s113ldom1:~/workspace$ file /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a: current ar archive, 32-bit symbol table I assumed that the error wrong ELF class: ELFCLASS32 was related to the archive created with incorrect compiler options. Regards, Aman On Friday, September 28, 2018 at 4:02:50 PM UTC-7, Ian Lance Taylor wrote: > On Fri, Sep 28, 2018 at 4:00 PM, > > wrote: > > Actually, I now understand what you meant. And even that does not work: > > > > amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ sudo > > GOPATH=/opt/go_pkgs CC='/home/amandeep/workspace/mygcc.sh' > CGO_CFLAGS='-m64' > > CGO_LDFLAGS='-m64' GOARCH=sparc64 CGO_ENABLED=1 go install -x > > -gccgoflags=-m64 > > WORK=/tmp/go-build445938530 > > mkdir -p $WORK/b001/ > > cd $WORK > > /usr/gnu/bin/gccgo -fgo-importcfg=/dev/null -c -x c - || true > > cd /opt/go_pkgs/src/github.com/golang/glog > > /usr/gnu/bin/gccgo -c -g -fdebug-prefix-map=$WORK=/tmp/go-build > > -gno-record-gcc-switches -fgo-pkgpath=github.com/golang/glog -o > > $WORK/b001/_go_.o -I $WORK/b001/_importcfgroot_ -m64 ./glog.go > > ./glog_file.go > > echo ' .section .go.buildid,"e"' >> $WORK/b001/_buildid.s > > echo ' .byte 0x79,0x71,0x58,0x37,0x74,0x64,0x76,0x6c' >> > > $WORK/b001/_buildid.s > > echo ' .byte 0x7a,0x59,0x53,0x39,0x41,0x6a,0x30,0x58' >> > > $WORK/b001/_buildid.s > > echo ' .byte 0x34,0x53,0x78,0x39,0x2f,0x79,0x71,0x58' >> > > $WORK/b001/_buildid.s > > echo ' .byte 0x37,0x74,0x64,0x76,0x6c,0x7a,0x59,0x53' >> > > $WORK/b001/_buildid.s > > echo ' .byte 0x39,0x41,0x6a,0x30,0x58,0x34,0x53,0x78' >> > > $WORK/b001/_buildid.s > > echo ' .byte 0x39' >> $WORK/b001/_buildid.s > > echo '' >> $WORK/b001/_buildid.s > > /usr/gnu/bin/gccgo -xassembler-with-cpp -I $WORK/b001/ -c -o > > $WORK/b001/_buildid.o -D GOOS_solaris -D GOARCH_sparc64 -D > > GOPKGPATH=github_com_golang_glog $WORK/b001/_buildid.s > > ar rcD $WORK/b001/_pkg_.a $WORK/b001/_go_.o $WORK/b001/_buildid.o > > /usr/gnu/libexec/gcc/sparc-sun-solaris2.11/8.2.1/buildid -w > > $WORK/b001/_pkg_.a # internal > > cp $WORK/b001/_pkg_.a > > > /root/.cache/go-build/a4/a47820a6bcb6e72c26a3be36129e80b12a0f0193dd5959e2c7304a3b169d9af8-d > > > > # internal > > mkdir -p /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/ > > cp $WORK/b001/_pkg_.a > > /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a > > rm -r $WORK/b001/ > > amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ ls -al > > /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a > > -rw-r--r-- 1 root root 611582 Sep 28 08:52 > > /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a > > amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ file > > /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a > > /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a: > > current ar archive, 32-bit symbol table > > > > The CC flag is not even honoured it would seem as I do not see any > > invocation related to mygcc.sh. Please advice. > > Do the same thing for gccgo and set the GCCGO environment variable to > that shell script. > > I'm not sure what you mean by "a 32-bit archive". Is that an archive > that contains 32-bit object files? The same hack should fix that, I > hope. > > Ian > > > > On Friday, September 28, 2018 at 3:23:43 PM UTC-7, aman...@cohesity.com > > wrote: > >> > >> hmm...filed a bug here: https://github.com/golang/go/issues/27929 > >> > >> Could you explain the workaround for this again? I did not understand > the > >> fallback option. > >> > >> Apart from that, I tried to run each command manually to force m64 > option > >> whenever possible. I was able to get a 64 bit executable for _buildid.o > but > >> even after that running ar rcD $WORK/b001/_pkg_.a $WORK/b001/_go_.o > >> $WORK/b001/_buildid.o produces a 32-bit archive. Also, running buildid > gives > >> some error abo
Re: [go-nuts] wrong ELF class error: How to compile 64 bit binary on Solaris 11 using gccgo
On Fri, Sep 28, 2018 at 4:00 PM, wrote: > Actually, I now understand what you meant. And even that does not work: > > amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ sudo > GOPATH=/opt/go_pkgs CC='/home/amandeep/workspace/mygcc.sh' CGO_CFLAGS='-m64' > CGO_LDFLAGS='-m64' GOARCH=sparc64 CGO_ENABLED=1 go install -x > -gccgoflags=-m64 > WORK=/tmp/go-build445938530 > mkdir -p $WORK/b001/ > cd $WORK > /usr/gnu/bin/gccgo -fgo-importcfg=/dev/null -c -x c - || true > cd /opt/go_pkgs/src/github.com/golang/glog > /usr/gnu/bin/gccgo -c -g -fdebug-prefix-map=$WORK=/tmp/go-build > -gno-record-gcc-switches -fgo-pkgpath=github.com/golang/glog -o > $WORK/b001/_go_.o -I $WORK/b001/_importcfgroot_ -m64 ./glog.go > ./glog_file.go > echo ' .section .go.buildid,"e"' >> $WORK/b001/_buildid.s > echo ' .byte 0x79,0x71,0x58,0x37,0x74,0x64,0x76,0x6c' >> > $WORK/b001/_buildid.s > echo ' .byte 0x7a,0x59,0x53,0x39,0x41,0x6a,0x30,0x58' >> > $WORK/b001/_buildid.s > echo ' .byte 0x34,0x53,0x78,0x39,0x2f,0x79,0x71,0x58' >> > $WORK/b001/_buildid.s > echo ' .byte 0x37,0x74,0x64,0x76,0x6c,0x7a,0x59,0x53' >> > $WORK/b001/_buildid.s > echo ' .byte 0x39,0x41,0x6a,0x30,0x58,0x34,0x53,0x78' >> > $WORK/b001/_buildid.s > echo ' .byte 0x39' >> $WORK/b001/_buildid.s > echo '' >> $WORK/b001/_buildid.s > /usr/gnu/bin/gccgo -xassembler-with-cpp -I $WORK/b001/ -c -o > $WORK/b001/_buildid.o -D GOOS_solaris -D GOARCH_sparc64 -D > GOPKGPATH=github_com_golang_glog $WORK/b001/_buildid.s > ar rcD $WORK/b001/_pkg_.a $WORK/b001/_go_.o $WORK/b001/_buildid.o > /usr/gnu/libexec/gcc/sparc-sun-solaris2.11/8.2.1/buildid -w > $WORK/b001/_pkg_.a # internal > cp $WORK/b001/_pkg_.a > /root/.cache/go-build/a4/a47820a6bcb6e72c26a3be36129e80b12a0f0193dd5959e2c7304a3b169d9af8-d > # internal > mkdir -p /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/ > cp $WORK/b001/_pkg_.a > /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a > rm -r $WORK/b001/ > amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ ls -al > /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a > -rw-r--r-- 1 root root 611582 Sep 28 08:52 > /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a > amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ file > /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a > /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a: > current ar archive, 32-bit symbol table > > The CC flag is not even honoured it would seem as I do not see any > invocation related to mygcc.sh. Please advice. Do the same thing for gccgo and set the GCCGO environment variable to that shell script. I'm not sure what you mean by "a 32-bit archive". Is that an archive that contains 32-bit object files? The same hack should fix that, I hope. Ian > On Friday, September 28, 2018 at 3:23:43 PM UTC-7, aman...@cohesity.com > wrote: >> >> hmm...filed a bug here: https://github.com/golang/go/issues/27929 >> >> Could you explain the workaround for this again? I did not understand the >> fallback option. >> >> Apart from that, I tried to run each command manually to force m64 option >> whenever possible. I was able to get a 64 bit executable for _buildid.o but >> even after that running ar rcD $WORK/b001/_pkg_.a $WORK/b001/_go_.o >> $WORK/b001/_buildid.o produces a 32-bit archive. Also, running buildid gives >> some error about 32 byte hash. Please see: >> >> amandeep@s113ldom1:~/workspace$ >> /usr/gnu/libexec/gcc/sparc-sun-solaris2.11/8.2.1/buildid -w >> $WORK/b001/_pkg_.a >> buildid: /tmp/go-build365019570/b001/_pkg_.a: cannot find 32-byte hash in >> id yqX7tdvlzYS9Aj0X4Sx9/yqX7tdvlzYS9Aj0X4Sx9 >> >> Let me know if any of this needs to be reported in the bug or if it >> provides more clarity on my situation here. >> >> On Friday, September 28, 2018 at 1:02:06 PM UTC-7, Ian Lance Taylor wrote: >>> >>> On Fri, Sep 28, 2018 at 10:14 AM, wrote: >>> > nopes...doesn't work either. I tried both variations...with and without >>> > GOARCH=sparc64 flag. Following is the output with sparc64 flag: >>> > >>> > amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ sudo >>> > GOPATH=/opt/go_pkgs CC='gcc -m64' CGO_CFLAGS='-m64' CGO_LDFLAGS='-m64' >>> > GOARCH=sparc64 CGO_ENABLED=1 go install -x -gccgoflags=-m64 >>> > WORK=/tmp/go-build365019570 >>> > mkdir -p $WORK/b001/ >>> > cd $WORK >>> > /usr/gnu/bin/gccgo -fgo-importcfg=/dev/null -c -x c - || true >>> > cd /opt/go_pkgs/src/github.com/golang/glog >>> > /usr/gnu/bin/gccgo -c -g -fdebug-prefix-map=$WORK=/tmp/go-build >>> > -gno-record-gcc-switches -fgo-pkgpath=github.com/golang/glog -o >>> > $WORK/b001/_go_.o -I $WORK/b001/_importcfgroot_ -m64 ./glog.go >>> > ./glog_file.go >>> > echo ' .section .go.buildid,"e"' >> $WORK/b001/_buildid.s >>> > echo ' .byte 0x79,0x71,0x58,0x37,0x74,0x64,0x76,0x6c' >> >>> > $WORK/b001/_buildid.s >>> > echo ' .byte 0x7a,0x59,0x53,0x39,0x41,0x6a,0x30,0x58' >> >>> > $WORK/b001/_buildid.s >>> > echo ' .byte 0x34,0x53,
Re: [go-nuts] wrong ELF class error: How to compile 64 bit binary on Solaris 11 using gccgo
Actually, I now understand what you meant. And even that does not work: amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ sudo GOPATH=/opt/go_pkgs CC='/home/amandeep/workspace/mygcc.sh' CGO_CFLAGS='-m64' CGO_LDFLAGS='-m64' GOARCH=sparc64 CGO_ENABLED=1 go install -x -gccgoflags=-m64 WORK=/tmp/go-build445938530 mkdir -p $WORK/b001/ cd $WORK /usr/gnu/bin/gccgo -fgo-importcfg=/dev/null -c -x c - || true cd /opt/go_pkgs/src/github.com/golang/glog /usr/gnu/bin/gccgo -c -g -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -fgo-pkgpath=github.com/golang/glog -o $WORK/b001/_go_.o -I $WORK/b001/_importcfgroot_ -m64 ./glog.go ./glog_file.go echo ' .section .go.buildid,"e"' >> $WORK/b001/_buildid.s echo ' .byte 0x79,0x71,0x58,0x37,0x74,0x64,0x76,0x6c' >> $WORK/b001/_buildid.s echo ' .byte 0x7a,0x59,0x53,0x39,0x41,0x6a,0x30,0x58' >> $WORK/b001/_buildid.s echo ' .byte 0x34,0x53,0x78,0x39,0x2f,0x79,0x71,0x58' >> $WORK/b001/_buildid.s echo ' .byte 0x37,0x74,0x64,0x76,0x6c,0x7a,0x59,0x53' >> $WORK/b001/_buildid.s echo ' .byte 0x39,0x41,0x6a,0x30,0x58,0x34,0x53,0x78' >> $WORK/b001/_buildid.s echo ' .byte 0x39' >> $WORK/b001/_buildid.s echo '' >> $WORK/b001/_buildid.s /usr/gnu/bin/gccgo -xassembler-with-cpp -I $WORK/b001/ -c -o $WORK/b001/_buildid.o -D GOOS_solaris -D GOARCH_sparc64 -D GOPKGPATH=github_com_golang_glog $WORK/b001/_buildid.s ar rcD $WORK/b001/_pkg_.a $WORK/b001/_go_.o $WORK/b001/_buildid.o /usr/gnu/libexec/gcc/sparc-sun-solaris2.11/8.2.1/buildid -w $WORK/b001/_pkg_.a # internal cp $WORK/b001/_pkg_.a /root/.cache/go-build/a4/a47820a6bcb6e72c26a3be36129e80b12a0f0193dd5959e2c7304a3b169d9af8-d # internal mkdir -p /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/ cp $WORK/b001/_pkg_.a /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a rm -r $WORK/b001/ amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ ls -al /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a -rw-r--r-- 1 root root 611582 Sep 28 08:52 /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ file /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a: current ar archive, 32-bit symbol table The CC flag is not even honoured it would seem as I do not see any invocation related to mygcc.sh. Please advice. On Friday, September 28, 2018 at 3:23:43 PM UTC-7, aman...@cohesity.com wrote: > > hmm...filed a bug here: https://github.com/golang/go/issues/27929 > > Could you explain the workaround for this again? I did not understand the > fallback option. > > Apart from that, I tried to run each command manually to force m64 option > whenever possible. I was able to get a 64 bit executable for _buildid.o but > even after that running ar rcD $WORK/b001/_pkg_.a $WORK/b001/_go_.o > $WORK/b001/_buildid.o produces a 32-bit archive. Also, running > buildid gives some error about 32 byte hash. Please see: > > amandeep@s113ldom1:~/workspace$ > /usr/gnu/libexec/gcc/sparc-sun-solaris2.11/8.2.1/buildid -w > $WORK/b001/_pkg_.a > buildid: /tmp/go-build365019570/b001/_pkg_.a: cannot find 32-byte hash in > id yqX7tdvlzYS9Aj0X4Sx9/yqX7tdvlzYS9Aj0X4Sx9 > > Let me know if any of this needs to be reported in the bug or if it > provides more clarity on my situation here. > > On Friday, September 28, 2018 at 1:02:06 PM UTC-7, Ian Lance Taylor wrote: >> >> On Fri, Sep 28, 2018 at 10:14 AM, wrote: >> > nopes...doesn't work either. I tried both variations...with and without >> > GOARCH=sparc64 flag. Following is the output with sparc64 flag: >> > >> > amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ sudo >> > GOPATH=/opt/go_pkgs CC='gcc -m64' CGO_CFLAGS='-m64' CGO_LDFLAGS='-m64' >> > GOARCH=sparc64 CGO_ENABLED=1 go install -x -gccgoflags=-m64 >> > WORK=/tmp/go-build365019570 >> > mkdir -p $WORK/b001/ >> > cd $WORK >> > /usr/gnu/bin/gccgo -fgo-importcfg=/dev/null -c -x c - || true >> > cd /opt/go_pkgs/src/github.com/golang/glog >> > /usr/gnu/bin/gccgo -c -g -fdebug-prefix-map=$WORK=/tmp/go-build >> > -gno-record-gcc-switches -fgo-pkgpath=github.com/golang/glog -o >> > $WORK/b001/_go_.o -I $WORK/b001/_importcfgroot_ -m64 ./glog.go >> > ./glog_file.go >> > echo ' .section .go.buildid,"e"' >> $WORK/b001/_buildid.s >> > echo ' .byte 0x79,0x71,0x58,0x37,0x74,0x64,0x76,0x6c' >> >> > $WORK/b001/_buildid.s >> > echo ' .byte 0x7a,0x59,0x53,0x39,0x41,0x6a,0x30,0x58' >> >> > $WORK/b001/_buildid.s >> > echo ' .byte 0x34,0x53,0x78,0x39,0x2f,0x79,0x71,0x58' >> >> > $WORK/b001/_buildid.s >> > echo ' .byte 0x37,0x74,0x64,0x76,0x6c,0x7a,0x59,0x53' >> >> > $WORK/b001/_buildid.s >> > echo ' .byte 0x39,0x41,0x6a,0x30,0x58,0x34,0x53,0x78' >> >> > $WORK/b001/_buildid.s >> > echo ' .byte 0x39' >> $WORK/b001/_buildid.s >> > echo '' >> $WORK/b001/_buildid.s >> > /usr/gnu/bin/gccgo -xassembler-with
Re: [go-nuts] wrong ELF class error: How to compile 64 bit binary on Solaris 11 using gccgo
hmm...filed a bug here: https://github.com/golang/go/issues/27929 Could you explain the workaround for this again? I did not understand the fallback option. Apart from that, I tried to run each command manually to force m64 option whenever possible. I was able to get a 64 bit executable for _buildid.o but even after that running ar rcD $WORK/b001/_pkg_.a $WORK/b001/_go_.o $WORK/b001/_buildid.o produces a 32-bit archive. Also, running buildid gives some error about 32 byte hash. Please see: amandeep@s113ldom1:~/workspace$ /usr/gnu/libexec/gcc/sparc-sun-solaris2.11/8.2.1/buildid -w $WORK/b001/_pkg_.a buildid: /tmp/go-build365019570/b001/_pkg_.a: cannot find 32-byte hash in id yqX7tdvlzYS9Aj0X4Sx9/yqX7tdvlzYS9Aj0X4Sx9 Let me know if any of this needs to be reported in the bug or if it provides more clarity on my situation here. On Friday, September 28, 2018 at 1:02:06 PM UTC-7, Ian Lance Taylor wrote: > > On Fri, Sep 28, 2018 at 10:14 AM, > > wrote: > > nopes...doesn't work either. I tried both variations...with and without > > GOARCH=sparc64 flag. Following is the output with sparc64 flag: > > > > amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ sudo > > GOPATH=/opt/go_pkgs CC='gcc -m64' CGO_CFLAGS='-m64' CGO_LDFLAGS='-m64' > > GOARCH=sparc64 CGO_ENABLED=1 go install -x -gccgoflags=-m64 > > WORK=/tmp/go-build365019570 > > mkdir -p $WORK/b001/ > > cd $WORK > > /usr/gnu/bin/gccgo -fgo-importcfg=/dev/null -c -x c - || true > > cd /opt/go_pkgs/src/github.com/golang/glog > > /usr/gnu/bin/gccgo -c -g -fdebug-prefix-map=$WORK=/tmp/go-build > > -gno-record-gcc-switches -fgo-pkgpath=github.com/golang/glog -o > > $WORK/b001/_go_.o -I $WORK/b001/_importcfgroot_ -m64 ./glog.go > > ./glog_file.go > > echo ' .section .go.buildid,"e"' >> $WORK/b001/_buildid.s > > echo ' .byte 0x79,0x71,0x58,0x37,0x74,0x64,0x76,0x6c' >> > > $WORK/b001/_buildid.s > > echo ' .byte 0x7a,0x59,0x53,0x39,0x41,0x6a,0x30,0x58' >> > > $WORK/b001/_buildid.s > > echo ' .byte 0x34,0x53,0x78,0x39,0x2f,0x79,0x71,0x58' >> > > $WORK/b001/_buildid.s > > echo ' .byte 0x37,0x74,0x64,0x76,0x6c,0x7a,0x59,0x53' >> > > $WORK/b001/_buildid.s > > echo ' .byte 0x39,0x41,0x6a,0x30,0x58,0x34,0x53,0x78' >> > > $WORK/b001/_buildid.s > > echo ' .byte 0x39' >> $WORK/b001/_buildid.s > > echo '' >> $WORK/b001/_buildid.s > > /usr/gnu/bin/gccgo -xassembler-with-cpp -I $WORK/b001/ -c -o > > $WORK/b001/_buildid.o -D GOOS_solaris -D GOARCH_sparc64 -D > > GOPKGPATH=github_com_golang_glog $WORK/b001/_buildid.s > > ar rcD $WORK/b001/_pkg_.a $WORK/b001/_go_.o $WORK/b001/_buildid.o > > /usr/gnu/libexec/gcc/sparc-sun-solaris2.11/8.2.1/buildid -w > > $WORK/b001/_pkg_.a # internal > > cp $WORK/b001/_pkg_.a > > > /root/.cache/go-build/a4/a47820a6bcb6e72c26a3be36129e80b12a0f0193dd5959e2c7304a3b169d9af8-d > > > > # internal > > mkdir -p /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/ > > cp $WORK/b001/_pkg_.a > > /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a > > rm -r $WORK/b001/ > > amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ file > > /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a > > /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a: > > current ar archive, 32-bit symbol table > > > > > > I think the problem is with the text in red. It gets the sparc64 flag, > but > > the executable is still having 32-bit MSB relocatable SPARC > > Let me know if you have any other suggestions. > > This sounds like a bug. I encourage you to file it at > https://golang.org/issue/new . > > There is always the fallback of using a shell script mygcc > > #!/bin/sh > exec gcc -m64 $* > > and setting CC=/path/to/mygcc > > Ian > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] wrong ELF class error: How to compile 64 bit binary on Solaris 11 using gccgo
On Fri, Sep 28, 2018 at 10:14 AM, wrote: > nopes...doesn't work either. I tried both variations...with and without > GOARCH=sparc64 flag. Following is the output with sparc64 flag: > > amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ sudo > GOPATH=/opt/go_pkgs CC='gcc -m64' CGO_CFLAGS='-m64' CGO_LDFLAGS='-m64' > GOARCH=sparc64 CGO_ENABLED=1 go install -x -gccgoflags=-m64 > WORK=/tmp/go-build365019570 > mkdir -p $WORK/b001/ > cd $WORK > /usr/gnu/bin/gccgo -fgo-importcfg=/dev/null -c -x c - || true > cd /opt/go_pkgs/src/github.com/golang/glog > /usr/gnu/bin/gccgo -c -g -fdebug-prefix-map=$WORK=/tmp/go-build > -gno-record-gcc-switches -fgo-pkgpath=github.com/golang/glog -o > $WORK/b001/_go_.o -I $WORK/b001/_importcfgroot_ -m64 ./glog.go > ./glog_file.go > echo ' .section .go.buildid,"e"' >> $WORK/b001/_buildid.s > echo ' .byte 0x79,0x71,0x58,0x37,0x74,0x64,0x76,0x6c' >> > $WORK/b001/_buildid.s > echo ' .byte 0x7a,0x59,0x53,0x39,0x41,0x6a,0x30,0x58' >> > $WORK/b001/_buildid.s > echo ' .byte 0x34,0x53,0x78,0x39,0x2f,0x79,0x71,0x58' >> > $WORK/b001/_buildid.s > echo ' .byte 0x37,0x74,0x64,0x76,0x6c,0x7a,0x59,0x53' >> > $WORK/b001/_buildid.s > echo ' .byte 0x39,0x41,0x6a,0x30,0x58,0x34,0x53,0x78' >> > $WORK/b001/_buildid.s > echo ' .byte 0x39' >> $WORK/b001/_buildid.s > echo '' >> $WORK/b001/_buildid.s > /usr/gnu/bin/gccgo -xassembler-with-cpp -I $WORK/b001/ -c -o > $WORK/b001/_buildid.o -D GOOS_solaris -D GOARCH_sparc64 -D > GOPKGPATH=github_com_golang_glog $WORK/b001/_buildid.s > ar rcD $WORK/b001/_pkg_.a $WORK/b001/_go_.o $WORK/b001/_buildid.o > /usr/gnu/libexec/gcc/sparc-sun-solaris2.11/8.2.1/buildid -w > $WORK/b001/_pkg_.a # internal > cp $WORK/b001/_pkg_.a > /root/.cache/go-build/a4/a47820a6bcb6e72c26a3be36129e80b12a0f0193dd5959e2c7304a3b169d9af8-d > # internal > mkdir -p /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/ > cp $WORK/b001/_pkg_.a > /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a > rm -r $WORK/b001/ > amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ file > /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a > /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a: > current ar archive, 32-bit symbol table > > > I think the problem is with the text in red. It gets the sparc64 flag, but > the executable is still having 32-bit MSB relocatable SPARC > Let me know if you have any other suggestions. This sounds like a bug. I encourage you to file it at https://golang.org/issue/new . There is always the fallback of using a shell script mygcc #!/bin/sh exec gcc -m64 $* and setting CC=/path/to/mygcc Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] wrong ELF class error: How to compile 64 bit binary on Solaris 11 using gccgo
nopes...doesn't work either. I tried both variations...with and without GOARCH=sparc64 flag. Following is the output with sparc64 flag: amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ sudo GOPATH=/opt/go_pkgs CC='gcc -m64' CGO_CFLAGS='-m64' CGO_LDFLAGS='-m64' GOARCH=sparc64 CGO_ENABLED=1 go install -x -gccgoflags=-m64 WORK=/tmp/go-build365019570 mkdir -p $WORK/b001/ cd $WORK /usr/gnu/bin/gccgo -fgo-importcfg=/dev/null -c -x c - || true cd /opt/go_pkgs/src/github.com/golang/glog /usr/gnu/bin/gccgo -c -g -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -fgo-pkgpath=github.com/golang/glog -o $WORK/b001/_go_.o -I $WORK/b001/_importcfgroot_ -m64 ./glog.go ./glog_file.go echo ' .section .go.buildid,"e"' >> $WORK/b001/_buildid.s echo ' .byte 0x79,0x71,0x58,0x37,0x74,0x64,0x76,0x6c' >> $WORK/b001/_buildid.s echo ' .byte 0x7a,0x59,0x53,0x39,0x41,0x6a,0x30,0x58' >> $WORK/b001/_buildid.s echo ' .byte 0x34,0x53,0x78,0x39,0x2f,0x79,0x71,0x58' >> $WORK/b001/_buildid.s echo ' .byte 0x37,0x74,0x64,0x76,0x6c,0x7a,0x59,0x53' >> $WORK/b001/_buildid.s echo ' .byte 0x39,0x41,0x6a,0x30,0x58,0x34,0x53,0x78' >> $WORK/b001/_buildid.s echo ' .byte 0x39' >> $WORK/b001/_buildid.s echo '' >> $WORK/b001/_buildid.s /usr/gnu/bin/gccgo -xassembler-with-cpp -I $WORK/b001/ -c -o $WORK/b001/_buildid.o -D GOOS_solaris -D GOARCH_sparc64 -D GOPKGPATH=github_com_golang_glog $WORK/b001/_buildid.s ar rcD $WORK/b001/_pkg_.a $WORK/b001/_go_.o $WORK/b001/_buildid.o /usr/gnu/libexec/gcc/sparc-sun-solaris2.11/8.2.1/buildid -w $WORK/b001/_pkg_.a # internal cp $WORK/b001/_pkg_.a /root/.cache/go-build/a4/a47820a6bcb6e72c26a3be36129e80b12a0f0193dd5959e2c7304a3b169d9af8-d # internal mkdir -p /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/ cp $WORK/b001/_pkg_.a /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a rm -r $WORK/b001/ amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ file /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a: current ar archive, 32-bit symbol table I think the problem is with the text in red. It gets the sparc64 flag, but the executable is still having 32-bit MSB relocatable SPARC Let me know if you have any other suggestions. On Friday, September 28, 2018 at 6:49:48 AM UTC-7, Ian Lance Taylor wrote: > > On Fri, Sep 28, 2018 at 12:43 AM, > > wrote: > > Seems like even that does not seem to work. Please see: > > > > amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ sudo > > GOPATH=/opt/go_pkgs CGO_CFLAGS='-m64' CGO_LDFLAGS='-m64' go install -x > > -gccgoflags=-m64 > > WORK=/tmp/go-build357879094 > > mkdir -p $WORK/b001/ > > cd $WORK > > /usr/gnu/bin/gccgo -fgo-importcfg=/dev/null -c -x c - || true > > cd /opt/go_pkgs/src/github.com/golang/glog > > /usr/gnu/bin/gccgo -c -g -fdebug-prefix-map=$WORK=/tmp/go-build > > -gno-record-gcc-switches -fgo-pkgpath=github.com/golang/glog -o > > $WORK/b001/_go_.o -I $WORK/b001/_importcfgroot_ -m64 ./glog.go > > ./glog_file.go > > echo ' .section .go.buildid,"e"' >> $WORK/b001/_buildid.s > > echo ' .byte 0x64,0x71,0x65,0x31,0x73,0x55,0x39,0x39' >> > > $WORK/b001/_buildid.s > > echo ' .byte 0x62,0x56,0x7a,0x36,0x52,0x57,0x35,0x74' >> > > $WORK/b001/_buildid.s > > echo ' .byte 0x64,0x55,0x59,0x4f,0x2f,0x64,0x71,0x65' >> > > $WORK/b001/_buildid.s > > echo ' .byte 0x31,0x73,0x55,0x39,0x39,0x62,0x56,0x7a' >> > > $WORK/b001/_buildid.s > > echo ' .byte 0x36,0x52,0x57,0x35,0x74,0x64,0x55,0x59' >> > > $WORK/b001/_buildid.s > > echo ' .byte 0x4f' >> $WORK/b001/_buildid.s > > echo '' >> $WORK/b001/_buildid.s > > /usr/gnu/bin/gccgo -xassembler-with-cpp -I $WORK/b001/ -c -o > > $WORK/b001/_buildid.o -D GOOS_solaris -D GOARCH_sparc -D > > GOPKGPATH=github_com_golang_glog $WORK/b001/_buildid.s > > ar rcD $WORK/b001/_pkg_.a $WORK/b001/_go_.o $WORK/b001/_buildid.o > > /usr/gnu/libexec/gcc/sparc-sun-solaris2.11/8.2.1/buildid -w > > $WORK/b001/_pkg_.a # internal > > cp $WORK/b001/_pkg_.a > > > /root/.cache/go-build/9d/9de1b3b9dc941395e2c0ba0bd363f9af9f8dc5c62c84b2d248c274ba14a2bcd7-d > > > > # internal > > mkdir -p /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/ > > cp $WORK/b001/_pkg_.a > > /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a > > rm -r $WORK/b001/ > > amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ file > > /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a > > /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a: > > current ar archive, 32-bit symbol table > > > > In the above output, I can see that -m64 flag is being passed to gcc, > but > > somehow does not seem to apply everywhere (one of the gccgo invocation > does > > not have -m64 flag). I tried to look at the generated archive and one of > the > > members is still 32bit MSB executable. Please look: > > > > amandeep@s113ldom1:~/wor
Re: [go-nuts] wrong ELF class error: How to compile 64 bit binary on Solaris 11 using gccgo
On Fri, Sep 28, 2018 at 12:43 AM, wrote: > Seems like even that does not seem to work. Please see: > > amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ sudo > GOPATH=/opt/go_pkgs CGO_CFLAGS='-m64' CGO_LDFLAGS='-m64' go install -x > -gccgoflags=-m64 > WORK=/tmp/go-build357879094 > mkdir -p $WORK/b001/ > cd $WORK > /usr/gnu/bin/gccgo -fgo-importcfg=/dev/null -c -x c - || true > cd /opt/go_pkgs/src/github.com/golang/glog > /usr/gnu/bin/gccgo -c -g -fdebug-prefix-map=$WORK=/tmp/go-build > -gno-record-gcc-switches -fgo-pkgpath=github.com/golang/glog -o > $WORK/b001/_go_.o -I $WORK/b001/_importcfgroot_ -m64 ./glog.go > ./glog_file.go > echo ' .section .go.buildid,"e"' >> $WORK/b001/_buildid.s > echo ' .byte 0x64,0x71,0x65,0x31,0x73,0x55,0x39,0x39' >> > $WORK/b001/_buildid.s > echo ' .byte 0x62,0x56,0x7a,0x36,0x52,0x57,0x35,0x74' >> > $WORK/b001/_buildid.s > echo ' .byte 0x64,0x55,0x59,0x4f,0x2f,0x64,0x71,0x65' >> > $WORK/b001/_buildid.s > echo ' .byte 0x31,0x73,0x55,0x39,0x39,0x62,0x56,0x7a' >> > $WORK/b001/_buildid.s > echo ' .byte 0x36,0x52,0x57,0x35,0x74,0x64,0x55,0x59' >> > $WORK/b001/_buildid.s > echo ' .byte 0x4f' >> $WORK/b001/_buildid.s > echo '' >> $WORK/b001/_buildid.s > /usr/gnu/bin/gccgo -xassembler-with-cpp -I $WORK/b001/ -c -o > $WORK/b001/_buildid.o -D GOOS_solaris -D GOARCH_sparc -D > GOPKGPATH=github_com_golang_glog $WORK/b001/_buildid.s > ar rcD $WORK/b001/_pkg_.a $WORK/b001/_go_.o $WORK/b001/_buildid.o > /usr/gnu/libexec/gcc/sparc-sun-solaris2.11/8.2.1/buildid -w > $WORK/b001/_pkg_.a # internal > cp $WORK/b001/_pkg_.a > /root/.cache/go-build/9d/9de1b3b9dc941395e2c0ba0bd363f9af9f8dc5c62c84b2d248c274ba14a2bcd7-d > # internal > mkdir -p /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/ > cp $WORK/b001/_pkg_.a > /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a > rm -r $WORK/b001/ > amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ file > /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a > /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a: > current ar archive, 32-bit symbol table > > In the above output, I can see that -m64 flag is being passed to gcc, but > somehow does not seem to apply everywhere (one of the gccgo invocation does > not have -m64 flag). I tried to look at the generated archive and one of the > members is still 32bit MSB executable. Please look: > > amandeep@s113ldom1:~/workspace$ ar -t > /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a > _go_.o > _buildid.o > amandeep@s113ldom1:~/workspace$ ar -xv > /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a ./_go_.o > ./_buildid.o > x - _go_.o > x - _buildid.o > amandeep@s113ldom1:~/workspace$ file ./_buildid.o > ./_buildid.o: ELF 32-bit MSB relocatable SPARC Version 1 > amandeep@s113ldom1:~/workspace$ file ./_go_.o > ./_go_.o: ELF 64-bit MSB relocatable SPARCV9 Version 1 > > Could that be the reason? > > I also tried providing GOARCH=sprac64 flag to see if that helps, but it > didn't. Similar output, just the file is generated in a different folder. > Please see: > > amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ sudo > GOPATH=/opt/go_pkgs CGO_CFLAGS='-m64' CGO_LDFLAGS='-m64' GOARCH=sparc64 > CGO_ENABLED=1 go install -x -gccgoflags=-m64 > WORK=/tmp/go-build328208181 > mkdir -p $WORK/b001/ > cd $WORK > /usr/gnu/bin/gccgo -fgo-importcfg=/dev/null -c -x c - || true > cd /opt/go_pkgs/src/github.com/golang/glog > /usr/gnu/bin/gccgo -c -g -fdebug-prefix-map=$WORK=/tmp/go-build > -gno-record-gcc-switches -fgo-pkgpath=github.com/golang/glog -o > $WORK/b001/_go_.o -I $WORK/b001/_importcfgroot_ -m64 ./glog.go > ./glog_file.go > echo ' .section .go.buildid,"e"' >> $WORK/b001/_buildid.s > echo ' .byte 0x79,0x71,0x58,0x37,0x74,0x64,0x76,0x6c' >> > $WORK/b001/_buildid.s > echo ' .byte 0x7a,0x59,0x53,0x39,0x41,0x6a,0x30,0x58' >> > $WORK/b001/_buildid.s > echo ' .byte 0x34,0x53,0x78,0x39,0x2f,0x79,0x71,0x58' >> > $WORK/b001/_buildid.s > echo ' .byte 0x37,0x74,0x64,0x76,0x6c,0x7a,0x59,0x53' >> > $WORK/b001/_buildid.s > echo ' .byte 0x39,0x41,0x6a,0x30,0x58,0x34,0x53,0x78' >> > $WORK/b001/_buildid.s > echo ' .byte 0x39' >> $WORK/b001/_buildid.s > echo '' >> $WORK/b001/_buildid.s > /usr/gnu/bin/gccgo -xassembler-with-cpp -I $WORK/b001/ -c -o > $WORK/b001/_buildid.o -D GOOS_solaris -D GOARCH_sparc64 -D > GOPKGPATH=github_com_golang_glog $WORK/b001/_buildid.s > ar rcD $WORK/b001/_pkg_.a $WORK/b001/_go_.o $WORK/b001/_buildid.o > /usr/gnu/libexec/gcc/sparc-sun-solaris2.11/8.2.1/buildid -w > $WORK/b001/_pkg_.a # internal > cp $WORK/b001/_pkg_.a > /root/.cache/go-build/a4/a47820a6bcb6e72c26a3be36129e80b12a0f0193dd5959e2c7304a3b169d9af8-d > # internal > mkdir -p /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/ > cp $WORK/b001/_pkg_.a > /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a > rm -r $WORK/b001/ > amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ file > /opt/go_pkgs/pkg/gccgo_
Re: [go-nuts] wrong ELF class error: How to compile 64 bit binary on Solaris 11 using gccgo
Seems like even that does not seem to work. Please see: amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ sudo GOPATH=/opt/go_pkgs CGO_CFLAGS='-m64' CGO_LDFLAGS='-m64' go install -x -gccgoflags=-m64 WORK=/tmp/go-build357879094 mkdir -p $WORK/b001/ cd $WORK /usr/gnu/bin/gccgo -fgo-importcfg=/dev/null -c -x c - || true cd /opt/go_pkgs/src/github.com/golang/glog /usr/gnu/bin/gccgo -c -g -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -fgo-pkgpath=github.com/golang/glog -o $WORK/b001/_go_.o -I $WORK/b001/_importcfgroot_ -m64 ./glog.go ./glog_file.go echo ' .section .go.buildid,"e"' >> $WORK/b001/_buildid.s echo ' .byte 0x64,0x71,0x65,0x31,0x73,0x55,0x39,0x39' >> $WORK/b001/_buildid.s echo ' .byte 0x62,0x56,0x7a,0x36,0x52,0x57,0x35,0x74' >> $WORK/b001/_buildid.s echo ' .byte 0x64,0x55,0x59,0x4f,0x2f,0x64,0x71,0x65' >> $WORK/b001/_buildid.s echo ' .byte 0x31,0x73,0x55,0x39,0x39,0x62,0x56,0x7a' >> $WORK/b001/_buildid.s echo ' .byte 0x36,0x52,0x57,0x35,0x74,0x64,0x55,0x59' >> $WORK/b001/_buildid.s echo ' .byte 0x4f' >> $WORK/b001/_buildid.s echo '' >> $WORK/b001/_buildid.s /usr/gnu/bin/gccgo -xassembler-with-cpp -I $WORK/b001/ -c -o $WORK/b001/_buildid.o -D GOOS_solaris -D GOARCH_sparc -D GOPKGPATH=github_com_golang_glog $WORK/b001/_buildid.s ar rcD $WORK/b001/_pkg_.a $WORK/b001/_go_.o $WORK/b001/_buildid.o /usr/gnu/libexec/gcc/sparc-sun-solaris2.11/8.2.1/buildid -w $WORK/b001/_pkg_.a # internal cp $WORK/b001/_pkg_.a /root/.cache/go-build/9d/9de1b3b9dc941395e2c0ba0bd363f9af9f8dc5c62c84b2d248c274ba14a2bcd7-d # internal mkdir -p /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/ cp $WORK/b001/_pkg_.a /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a rm -r $WORK/b001/ amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ file /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a: current ar archive, 32-bit symbol table In the above output, I can see that -m64 flag is being passed to gcc, but somehow does not seem to apply everywhere (one of the gccgo invocation does not have -m64 flag). I tried to look at the generated archive and one of the members is still 32bit MSB executable. Please look: amandeep@s113ldom1:~/workspace$ ar -t /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a _go_.o _buildid.o amandeep@s113ldom1:~/workspace$ ar -xv /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a ./_go_.o ./_buildid.o x - _go_.o x - _buildid.o amandeep@s113ldom1:~/workspace$ file ./_buildid.o ./_buildid.o: ELF 32-bit MSB relocatable SPARC Version 1 amandeep@s113ldom1:~/workspace$ file ./_go_.o ./_go_.o: ELF 64-bit MSB relocatable SPARCV9 Version 1 Could that be the reason? I also tried providing GOARCH=sprac64 flag to see if that helps, but it didn't. Similar output, just the file is generated in a different folder. Please see: amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ sudo GOPATH=/opt/go_pkgs CGO_CFLAGS='-m64' CGO_LDFLAGS='-m64' GOARCH=sparc64 CGO_ENABLED=1 go install -x -gccgoflags=-m64 WORK=/tmp/go-build328208181 mkdir -p $WORK/b001/ cd $WORK /usr/gnu/bin/gccgo -fgo-importcfg=/dev/null -c -x c - || true cd /opt/go_pkgs/src/github.com/golang/glog /usr/gnu/bin/gccgo -c -g -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -fgo-pkgpath=github.com/golang/glog -o $WORK/b001/_go_.o -I $WORK/b001/_importcfgroot_ -m64 ./glog.go ./glog_file.go echo ' .section .go.buildid,"e"' >> $WORK/b001/_buildid.s echo ' .byte 0x79,0x71,0x58,0x37,0x74,0x64,0x76,0x6c' >> $WORK/b001/_buildid.s echo ' .byte 0x7a,0x59,0x53,0x39,0x41,0x6a,0x30,0x58' >> $WORK/b001/_buildid.s echo ' .byte 0x34,0x53,0x78,0x39,0x2f,0x79,0x71,0x58' >> $WORK/b001/_buildid.s echo ' .byte 0x37,0x74,0x64,0x76,0x6c,0x7a,0x59,0x53' >> $WORK/b001/_buildid.s echo ' .byte 0x39,0x41,0x6a,0x30,0x58,0x34,0x53,0x78' >> $WORK/b001/_buildid.s echo ' .byte 0x39' >> $WORK/b001/_buildid.s echo '' >> $WORK/b001/_buildid.s /usr/gnu/bin/gccgo -xassembler-with-cpp -I $WORK/b001/ -c -o $WORK/b001/_buildid.o -D GOOS_solaris -D GOARCH_sparc64 -D GOPKGPATH=github_com_golang_glog $WORK/b001/_buildid.s ar rcD $WORK/b001/_pkg_.a $WORK/b001/_go_.o $WORK/b001/_buildid.o /usr/gnu/libexec/gcc/sparc-sun-solaris2.11/8.2.1/buildid -w $WORK/b001/_pkg_.a # internal cp $WORK/b001/_pkg_.a /root/.cache/go-build/a4/a47820a6bcb6e72c26a3be36129e80b12a0f0193dd5959e2c7304a3b169d9af8-d # internal mkdir -p /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/ cp $WORK/b001/_pkg_.a /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a rm -r $WORK/b001/ amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ file /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a /opt/go_pkgs/pkg/gccgo_solaris_sparc64/github.com/golang/libglog.a: current ar archive, 32-bit symbol table I also gave compiling the helloworld file a tr
Re: [go-nuts] wrong ELF class error: How to compile 64 bit binary on Solaris 11 using gccgo
On Thu, Sep 27, 2018 at 5:34 PM, wrote: > Yes, this works for a simple program I have. Now I modified the helloworld > to use glog as follows: > > package main > > import ( > "fmt" > "github.com/golang/glog" > ) > > func main() { > fmt.Println("Hello world") > glog.Info("Hello world...") > } > > But now I get another error from libglog.a: > > amandeep@s113ldom1:~/workspace$ go build -gccgoflags=-m64 helloworld.go > # command-line-arguments > ld: warning: file > /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a(_go_.o): > wrong ELF class: ELFCLASS32 > Undefined first referenced > symbol in file > github_com_golang_glog..import $WORK/b001/_pkg_.a(_go_.o) > github_com_golang_glog.Info $WORK/b001/_pkg_.a(_go_.o) > ld: fatal: symbol referencing errors > collect2: error: ld returned 1 exit status > > So, I thought recompiling glog with 64 bit option would help. None of the > following helped: > > sudo GOPATH=/opt/go_pkgs/ CGO_LDFLAGS='-m64' go install > sudo GOPATH=/opt/go_pkgs/ go install -gccgoflags '-m64' > sudo GOPATH=/opt/go_pkgs/ go install -gccgoflags='-m64' > > All of these generate the following: > > amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ file > /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a > /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a: > current ar archive, 32-bit symbol table For a package that uses cgo, you'll need to use -gccgoflags=-m64 and also set both CGO_CFLAGS and CGO_LDFLAGS to -m64. Ian > On Thursday, September 27, 2018 at 3:01:12 PM UTC-7, Ian Lance Taylor wrote: >> >> On Thu, Sep 27, 2018 at 2:57 PM, Amandeep Gautam >> wrote: >> > Hi, >> >I am trying to compile a 64bit executable using gccgo on Solaris >> > 11/10. >> > Following is what I have tried: >> > >> > CGO_LDFLAGS='-m64' go build hello_world.go >> > GOARCH=sparc64 CGO_LDFLAGS='-m64' go build hello_world.go >> > >> > Below is the output of the first command: >> > >> > amandeep@s113ldom1:~/workspace$ CGO_LDFLAGS='-m64' go build pqrs.go >> > # command-line-arguments >> > ld: warning: file $WORK/b001/_pkg_.a(_go_.o): wrong ELF class: >> > ELFCLASS32 >> > Undefined first referenced >> > symbol in file >> > main.main >> > /usr/gnu/lib/gcc/sparc-sun-solaris2.11/8.2.1/../../../sparcv9/libgo.so >> > __go_init_main >> > /usr/gnu/lib/gcc/sparc-sun-solaris2.11/8.2.1/../../../sparcv9/libgo.so >> > ld: fatal: symbol referencing errors >> > collect2: error: ld returned 1 exit status >> > >> > However, I am able to generate 64 bit executable for c++ helloworld >> > using >> > just gcc, so I am hoping it boils down to passing the right set of >> > flags. >> > For example: >> > >> > amandeep@s113ldom1:~/workspace$ /usr/gnu/bin/gcc -m64 helloworld.c >> > amandeep@s113ldom1:~/workspace$ file ./a.out >> > ./a.out:ELF 64-bit MSB executable SPARCV9 Version 1, dynamically >> > linked, not stripped, no debugging information available >> > amandeep@s113ldom1:~/workspace$ file /usr/gnu/bin/gcc >> > /usr/gnu/bin/gcc: ELF 32-bit MSB executable SPARC32PLUS Version 1, >> > V8+ >> > Required, dynamically linked, not stripped >> > >> > How would you compile a 64 bit executable for Solaris using gccgo? >> >> CGO_LDFLAGS only affects your program if it actually uses cgo. >> >> Does it work to do >> go build -gccgoflags=-m64 >> ? > > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] wrong ELF class error: How to compile 64 bit binary on Solaris 11 using gccgo
Yes, this works for a simple program I have. Now I modified the helloworld to use glog as follows: package main import ( "fmt" "github.com/golang/glog" ) func main() { fmt.Println("Hello world") glog.Info("Hello world...") } But now I get another error from libglog.a: amandeep@s113ldom1:~/workspace$ go build -gccgoflags=-m64 helloworld.go # command-line-arguments ld: warning: file /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a(_go_.o): wrong ELF class: ELFCLASS32 Undefined first referenced symbol in file github_com_golang_glog..import $WORK/b001/_pkg_.a(_go_.o) github_com_golang_glog.Info $WORK/b001/_pkg_.a(_go_.o) ld: fatal: symbol referencing errors collect2: error: ld returned 1 exit status So, I thought recompiling glog with 64 bit option would help. None of the following helped: sudo GOPATH=/opt/go_pkgs/ CGO_LDFLAGS='-m64' go install sudo GOPATH=/opt/go_pkgs/ go install -gccgoflags '-m64' sudo GOPATH=/opt/go_pkgs/ go install -gccgoflags='-m64' All of these generate the following: amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ file /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a /opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a: current ar archive, 32-bit symbol table Regards, Aman On Thursday, September 27, 2018 at 3:01:12 PM UTC-7, Ian Lance Taylor wrote: > > On Thu, Sep 27, 2018 at 2:57 PM, Amandeep Gautam > > wrote: > > Hi, > >I am trying to compile a 64bit executable using gccgo on Solaris > 11/10. > > Following is what I have tried: > > > > CGO_LDFLAGS='-m64' go build hello_world.go > > GOARCH=sparc64 CGO_LDFLAGS='-m64' go build hello_world.go > > > > Below is the output of the first command: > > > > amandeep@s113ldom1:~/workspace$ CGO_LDFLAGS='-m64' go build pqrs.go > > # command-line-arguments > > ld: warning: file $WORK/b001/_pkg_.a(_go_.o): wrong ELF class: > ELFCLASS32 > > Undefined first referenced > > symbol in file > > main.main > > /usr/gnu/lib/gcc/sparc-sun-solaris2.11/8.2.1/../../../sparcv9/libgo.so > > __go_init_main > > /usr/gnu/lib/gcc/sparc-sun-solaris2.11/8.2.1/../../../sparcv9/libgo.so > > ld: fatal: symbol referencing errors > > collect2: error: ld returned 1 exit status > > > > However, I am able to generate 64 bit executable for c++ helloworld > using > > just gcc, so I am hoping it boils down to passing the right set of > flags. > > For example: > > > > amandeep@s113ldom1:~/workspace$ /usr/gnu/bin/gcc -m64 helloworld.c > > amandeep@s113ldom1:~/workspace$ file ./a.out > > ./a.out:ELF 64-bit MSB executable SPARCV9 Version 1, dynamically > > linked, not stripped, no debugging information available > > amandeep@s113ldom1:~/workspace$ file /usr/gnu/bin/gcc > > /usr/gnu/bin/gcc: ELF 32-bit MSB executable SPARC32PLUS Version 1, > V8+ > > Required, dynamically linked, not stripped > > > > How would you compile a 64 bit executable for Solaris using gccgo? > > CGO_LDFLAGS only affects your program if it actually uses cgo. > > Does it work to do > go build -gccgoflags=-m64 > ? > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] wrong ELF class error: How to compile 64 bit binary on Solaris 11 using gccgo
On Thu, Sep 27, 2018 at 2:57 PM, Amandeep Gautam wrote: > Hi, >I am trying to compile a 64bit executable using gccgo on Solaris 11/10. > Following is what I have tried: > > CGO_LDFLAGS='-m64' go build hello_world.go > GOARCH=sparc64 CGO_LDFLAGS='-m64' go build hello_world.go > > Below is the output of the first command: > > amandeep@s113ldom1:~/workspace$ CGO_LDFLAGS='-m64' go build pqrs.go > # command-line-arguments > ld: warning: file $WORK/b001/_pkg_.a(_go_.o): wrong ELF class: ELFCLASS32 > Undefined first referenced > symbol in file > main.main > /usr/gnu/lib/gcc/sparc-sun-solaris2.11/8.2.1/../../../sparcv9/libgo.so > __go_init_main > /usr/gnu/lib/gcc/sparc-sun-solaris2.11/8.2.1/../../../sparcv9/libgo.so > ld: fatal: symbol referencing errors > collect2: error: ld returned 1 exit status > > However, I am able to generate 64 bit executable for c++ helloworld using > just gcc, so I am hoping it boils down to passing the right set of flags. > For example: > > amandeep@s113ldom1:~/workspace$ /usr/gnu/bin/gcc -m64 helloworld.c > amandeep@s113ldom1:~/workspace$ file ./a.out > ./a.out:ELF 64-bit MSB executable SPARCV9 Version 1, dynamically > linked, not stripped, no debugging information available > amandeep@s113ldom1:~/workspace$ file /usr/gnu/bin/gcc > /usr/gnu/bin/gcc: ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ > Required, dynamically linked, not stripped > > How would you compile a 64 bit executable for Solaris using gccgo? CGO_LDFLAGS only affects your program if it actually uses cgo. Does it work to do go build -gccgoflags=-m64 ? Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.