Re: [go-nuts] wrong ELF class error: How to compile 64 bit binary on Solaris 11 using gccgo

2018-10-01 Thread amandeep
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

2018-09-28 Thread amandeep
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/i

Re: [go-nuts] wrong ELF class error: How to compile 64 bit binary on Solaris 11 using gccgo

2018-09-28 Thread amandeep
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

Re: [go-nuts] wrong ELF class error: How to compile 64 bit binary on Solaris 11 using gccgo

2018-09-28 Thread amandeep
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

2018-09-28 Thread amandeep
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/lib

Re: [go-nuts] wrong ELF class error: How to compile 64 bit binary on Solaris 11 using gccgo

2018-09-28 Thread amandeep
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/

[go-nuts] wrong ELF class error: How to compile 64 bit binary on Solaris 11 using gccgo

2018-09-27 Thread Amandeep Gautam
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?

-- 
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] call of non-function C.testc

2018-09-24 Thread amandeep
Hello Ian,
   Since you mention about 32-bit SPARC, I did a little testing. It seems 
that gccgo is compiling 32-bit binary by default:
-bash-4.3$ go build abcd.go 
-bash-4.3$ file abcd
abcd:   ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ 
Required, dynamically linked, not stripped

However, it does not look like a 32-bit SPARC. Please see below:

-bash-4.3$ isainfo -v
64-bit sparcv9 applications
crc32c cbcond pause mont mpmul sha512 sha256 sha1 md5 camellia des 
aes 
ima hpc vis3 fmaf asi_blk_init vis2 vis popc 
32-bit sparc applications
crc32c cbcond pause mont mpmul sha512 sha256 sha1 md5 camellia des 
aes 
ima hpc vis3 fmaf asi_blk_init vis2 vis popc v8plus div32 mul32 

How would I compile a 64-bit executable? Maybe that would work (exporting 
CFLAGS=-m64 does not seem to work)

Regards,
Aman

On Monday, September 24, 2018 at 8:31:02 PM UTC-7, Ian Lance Taylor wrote:
>
> On Mon, Sep 24, 2018 at 7:21 PM,  > 
> wrote: 
> > 
> >I configured everything from scratch again and it seems that this is 
> > reproducible. I also noticed that while running: 
> > CGO_LDFLAGS='"-g" "-O2"' 
> > /usr/gnu/libexec/gcc/sparc-sun-solaris2.10/8.2.1/cgo -debug-gcc -objdir 
> > $WORK/b001/ -importpath command-line-arguments -gccgo -- -I $WORK/b001/ 
> -g 
> > -O2 ./sol10.go 
> > we see an error: 
> > not-type:1:33: error: '__cgo_undefined__2' undeclared (first use in this 
> > function); did you mean '__cgo_f_1_2'? 
> > Could that be an issue? 
>
> That is normal enough.  What cgo does is create a little file, compile 
> it, and then examine which lines get errors.  And error on this line 
> means that the corresponding symbol is not a type. 
>
>
> > This looks awfully similar to https://github.com/golang/go/issues/18959. 
>
>
> Hmmm, that could indeed be the problem if this is 32-bit SPARC. 
>
>
> > I also created a bug: https://github.com/golang/go/issues/27838 with 
> all the 
> > details. 
>
> Thanks. 
>
> 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] call of non-function C.testc

2018-09-24 Thread amandeep
b17 R_SPARC_UA32     .debug_str + 40 
> >> > 014c  0b17 R_SPARC_UA32     .debug_str + 26 
> >> > 0165  0b17 R_SPARC_UA32     .debug_str + 175 
> >> > 0173  0b17 R_SPARC_UA32     .debug_str + 32 
> >> > 018c  0b17 R_SPARC_UA32     .debug_str + 7d 
> >> > 019a  0b17 R_SPARC_UA32     .debug_str + 159 
> >> > 01ae  0b17 R_SPARC_UA32     .debug_str + f0 
> >> > 01bd  0b17 R_SPARC_UA32     .debug_str + a7 
> >> > 01cc  0b17 R_SPARC_UA32     .debug_str + 39 
> >> > 01db  0b17 R_SPARC_UA32     .debug_str + 76 
> >> > 01f1  0b17 R_SPARC_UA32     .debug_str + 136 
> >> > 01ff  1117 R_SPARC_UA32  0004   __cgo__0 + 0 
> >> > 021a  0b17 R_SPARC_UA32     .debug_str + ce 
> >> > 0228  1017 R_SPARC_UA32  0010   __cgodebug_ints + 0 
> >> > 023f  0b17 R_SPARC_UA32     .debug_str + c7 
> >> > 0244  0b17 R_SPARC_UA32     .debug_str + d 
> >> > 0252  0f17 R_SPARC_UA32     __cgodebug_floats + 0 
> >> > 0258  0b17 R_SPARC_UA32     .debug_str + a1 
> >> > 025f  0217 R_SPARC_UA32     .text + 0 
> >> > 0263  0217 R_SPARC_UA32     .text + 14 
> >> > 0270  0217 R_SPARC_UA32     .text + 14 
> >> > 0284  0b17 R_SPARC_UA32     .debug_str + 12f 
> >> > 0288  0b17 R_SPARC_UA32     .debug_str + 12f 
> >> > 
> >> > Relocation section '.rela.debug_aranges' at offset 0xec8 contains 2 
> >> > entries: 
> >> >  Offset InfoTypeSym.Value  Sym. Name + Addend 
> >> > 0006  0717 R_SPARC_UA32     .debug_info + 0 
> >> > 0010  0217 R_SPARC_UA32     .text + 0 
> >> > 
> >> > Relocation section '.rela.debug_line' at offset 0xee0 contains 1 
> >> > entries: 
> >> >  Offset InfoTypeSym.Value  Sym. Name + Addend 
> >> > 011b  0217 R_SPARC_UA32     .text + 0 
> >> > 
> >> > The decoding of unwind sections for machine type Sparc is not 
> currently 
> >> > supported. 
> >> > 
> >> > Symbol table '.symtab' contains 18 entries: 
> >> >Num:Value  Size TypeBind   Vis  Ndx Name 
> >> >  0:  0 NOTYPE  LOCAL  DEFAULT  UND 
> >> >  1:  0 FILELOCAL  DEFAULT  ABS 
> >> >  2:  0 SECTION LOCAL  DEFAULT1 
> >> >  3:  0 SECTION LOCAL  DEFAULT3 
> >> >  4:  0 SECTION LOCAL  DEFAULT4 
> >> >  5:  0 SECTION LOCAL  DEFAULT5 
> >> >  6:  0 SECTION LOCAL  DEFAULT6 
> >> >  7:  0 SECTION LOCAL  DEFAULT8 
> >> >  8:  0 SECTION LOCAL  DEFAULT   10 
> >> >  9:  0 SECTION LOCAL  DEFAULT   11 
> >> > 10:  0 SECTION LOCAL  DEFAULT   13 
> >> > 11:  0 SECTION LOCAL  DEFAULT   15 
> >> > 12:  0 SECTION LOCAL  DEFAULT   16 
> >> > 13: 20 FUNCGLOBAL DEFAULT1 testc 
> >> > 14:  0 NOTYPE  GLOBAL DEFAULT  UND printf 
> >> > 15: 16 OBJECT  GLOBAL DEFAULT3 __cgodebug_floats 
> >> > 16: 001016 OBJECT  GLOBAL DEFAULT3 __cgodebug_ints 
> >> > 17: 0004 4 OBJECT  GLOBAL DEFAULT  COM __cgo__0 
> >> > 
> >> > No version information found in this file. 
> >> > Contents of the .debug_frame section: 
> >> > 
> >> >  000c  CIE 
> >> >   Version:   1 
> >> >   Augmentation:  "" 
> >> >   Code alignment factor: 1 
> >> >   Data alignment factor: -4 
> >> >   Return address column: 15 
> >> > 
> >> >   DW_CFA_def_cfa: r14 ofs 0 
> >> > 
> >> > 0010 000c  FDE cie= pc=..0014 
> >> > 
> >> > Contents of the .debug_info section: 
> >> > 
> >> >   Compilation Unit @ offset 0x0: 
>

Re: [go-nuts] call of non-function C.testc

2018-09-18 Thread amandeep
   Num:Value  Size TypeBind   Vis  Ndx Name 
> >  0:  0 NOTYPE  LOCAL  DEFAULT  UND 
> >  1:  0 FILELOCAL  DEFAULT  ABS 
> >  2:  0 SECTION LOCAL  DEFAULT1 
> >  3:  0 SECTION LOCAL  DEFAULT3 
> >  4:  0 SECTION LOCAL  DEFAULT4 
> >  5:  0 SECTION LOCAL  DEFAULT5 
> >  6:  0 SECTION LOCAL  DEFAULT6 
> >  7:  0 SECTION LOCAL  DEFAULT8 
> >  8:  0 SECTION LOCAL  DEFAULT   10 
> >  9:  0 SECTION LOCAL  DEFAULT   11 
> > 10:  0 SECTION LOCAL  DEFAULT   13 
> > 11:  0 SECTION LOCAL  DEFAULT   15 
> > 12:  0 SECTION LOCAL  DEFAULT   16 
> > 13: 20 FUNCGLOBAL DEFAULT1 testc 
> > 14:  0 NOTYPE  GLOBAL DEFAULT  UND printf 
> > 15: 000016 OBJECT  GLOBAL DEFAULT3 __cgodebug_floats 
> > 16: 001016 OBJECT  GLOBAL DEFAULT3 __cgodebug_ints 
> > 17: 0004 4 OBJECT  GLOBAL DEFAULT  COM __cgo__0 
> > 
> > No version information found in this file. 
> > Contents of the .debug_frame section: 
> > 
> >  000c  CIE 
> >   Version:   1 
> >   Augmentation:  "" 
> >   Code alignment factor: 1 
> >   Data alignment factor: -4 
> >   Return address column: 15 
> > 
> >   DW_CFA_def_cfa: r14 ofs 0 
> > 
> > 0010 000c  FDE cie= pc=..0014 
> > 
> > Contents of the .debug_info section: 
> > 
> >   Compilation Unit @ offset 0x0: 
> >Length:0x28c (32-bit) 
> >Version:   2 
> >Abbrev Offset: 0x0 
> >Pointer Size:  4 
> >  <0>: Abbrev Number: 1 (DW_TAG_compile_unit) 
> >DW_AT_producer: (indirect string, offset: 0x45): GNU C17 
> 8.2.1 
> > 20180814 -mcpu=v9 -gdwarf-2 -g -O2 
> > <10>   DW_AT_language: 12   (ANSI C99) 
> > <11>   DW_AT_comp_dir: (indirect string, offset: 0x10b): 
> > /export/home/amandeep 
> > <15>   DW_AT_low_pc  : 0x0 
> > <19>   DW_AT_high_pc : 0x14 
> > <1d>   DW_AT_stmt_list   : 0x0 
> >  <1><21>: Abbrev Number: 2 (DW_TAG_base_type) 
> > <22>   DW_AT_byte_size   : 4 
> > <23>   DW_AT_encoding: 5(signed) 
> > <24>   DW_AT_name: int 
> >  <1><28>: Abbrev Number: 3 (DW_TAG_base_type) 
> > <29>   DW_AT_byte_size   : 4 
> > <2a>   DW_AT_encoding: 7(unsigned) 
> > <2b>   DW_AT_name: (indirect string, offset: 0xe3): unsigned 
> int 
> >  <1><2f>: Abbrev Number: 3 (DW_TAG_base_type) 
> > <30>   DW_AT_byte_size   : 4 
> > <31>   DW_AT_encoding: 5(signed) 
> > <32>   DW_AT_name: (indirect string, offset: 0x13f): long 
> int 
> >  <1><36>: Abbrev Number: 3 (DW_TAG_base_type) 
> > <37>   DW_AT_byte_size   : 8 
> > <38>   DW_AT_encoding: 5(signed) 
> > <39>   DW_AT_name: (indirect string, offset: 0x121): long 
> long 
> > int 
> >  <1><3d>: Abbrev Number: 3 (DW_TAG_base_type) 
> > <3e>   DW_AT_byte_size   : 16 
> > <3f>   DW_AT_encoding: 4(float) 
> > <40>   DW_AT_name: (indirect string, offset: 0x14d): long 
> double 
> >  <1><44>: Abbrev Number: 3 (DW_TAG_base_type) 
> > <45>   DW_AT_byte_size   : 1 
> > <46>   DW_AT_encoding: 6(signed char) 
> > <47>   DW_AT_name: (indirect string, offset: 0x100): char 
> >  <1><4b>: Abbrev Number: 4 (DW_TAG_pointer_type) 
> > <4c>   DW_AT_byte_size   : 4 
> > <4d>   DW_AT_type: <0x44> 
> >  <1><51>: Abbrev Number: 5 (DW_TAG_typedef) 
> > <52>   DW_AT_name: (indirect string, offset: 0x1f): __FILE 
> > <56>   DW_AT_decl_file   : 3 
> > <57>   DW_AT_decl_line   : 21 
> > <58>   DW_AT_decl_column : 27 
> > <59>   DW_AT_type: <0x5d> 
> >  <1><5d>: Abbrev Number: 6 (DW_TAG_structure_type) 
> > <5e>   DW_AT_name: (indirect string, offset: 0x1f): __FILE 
> > <62>   DW_AT_byte_size   : 16 
> > <63>   DW_AT_decl_file   : 2 
>

Re: [go-nuts] call of non-function C.testc

2018-09-14 Thread amandeep
     .debug_str + 2c
00a7  0b17 R_SPARC_UA32     .debug_str + 105
00b6  0b17 R_SPARC_UA32     .debug_str + 88
00c8  0b17 R_SPARC_UA32     .debug_str + 96
00da  0b17 R_SPARC_UA32     .debug_str + bc
00ec  0b17 R_SPARC_UA32     .debug_str + 0
00fe  0b17 R_SPARC_UA32     .debug_str + 168
0110  0b17 R_SPARC_UA32     .debug_str + f7
012b  0b17 R_SPARC_UA32     .debug_str + ae
0130  0b17 R_SPARC_UA32     .debug_str + 40
014c  0b17 R_SPARC_UA32     .debug_str + 26
0165  0b17 R_SPARC_UA32     .debug_str + 175
0173  0b17 R_SPARC_UA32     .debug_str + 32
018c  0b17 R_SPARC_UA32     .debug_str + 7d
019a  0b17 R_SPARC_UA32     .debug_str + 159
01ae  0b17 R_SPARC_UA32     .debug_str + f0
01bd  0b17 R_SPARC_UA32     .debug_str + a7
01cc  0b17 R_SPARC_UA32     .debug_str + 39
01db  0b17 R_SPARC_UA32     .debug_str + 76
01f1  0b17 R_SPARC_UA32     .debug_str + 136
01ff  1117 R_SPARC_UA32  0004   __cgo__0 + 0
021a  0b17 R_SPARC_UA32     .debug_str + ce
0228  1017 R_SPARC_UA32  0010   __cgodebug_ints + 0
023f  0b17 R_SPARC_UA32     .debug_str + c7
0244  0b17 R_SPARC_UA32     .debug_str + d
0252  0f17 R_SPARC_UA32     __cgodebug_floats + 0
0258  0b17 R_SPARC_UA32     .debug_str + a1
025f  0217 R_SPARC_UA32     .text + 0
0263  0217 R_SPARC_UA32     .text + 14
0270  0217 R_SPARC_UA32     .text + 14
0284  0b17 R_SPARC_UA32     .debug_str + 12f
0288  0b17 R_SPARC_UA32     .debug_str + 12f

Relocation section '.rela.debug_aranges' at offset 0xec8 contains 2 entries:
 Offset InfoTypeSym.Value  Sym. Name + Addend
0006  0717 R_SPARC_UA32     .debug_info + 0
0010  0217 R_SPARC_UA32     .text + 0

Relocation section '.rela.debug_line' at offset 0xee0 contains 1 entries:
 Offset InfoTypeSym.Value  Sym. Name + Addend
011b  0217 R_SPARC_UA32     .text + 0

The decoding of unwind sections for machine type Sparc is not currently 
supported.

Symbol table '.symtab' contains 18 entries:
   Num:Value  Size TypeBind   Vis  Ndx Name
 0:  0 NOTYPE  LOCAL  DEFAULT  UND 
 1:  0 FILELOCAL  DEFAULT  ABS 
 2:  0 SECTION LOCAL  DEFAULT1 
 3:  0 SECTION LOCAL  DEFAULT3 
 4:  0 SECTION LOCAL  DEFAULT4 
 5:  0 SECTION LOCAL  DEFAULT5 
 6:  0 SECTION LOCAL  DEFAULT6 
 7:  0 SECTION LOCAL  DEFAULT8 
 8:  0 SECTION LOCAL  DEFAULT   10 
 9:  0 SECTION LOCAL  DEFAULT   11 
10:  0 SECTION LOCAL  DEFAULT   13 
11:  0 SECTION LOCAL  DEFAULT   15 
12:  0 SECTION LOCAL  DEFAULT   16 
13: 20 FUNCGLOBAL DEFAULT1 testc
14:  0 NOTYPE  GLOBAL DEFAULT  UND printf
15: 16 OBJECT  GLOBAL DEFAULT3 __cgodebug_floats
16: 001016 OBJECT  GLOBAL DEFAULT3 __cgodebug_ints
17: 0004 4 OBJECT  GLOBAL DEFAULT  COM __cgo__0

No version information found in this file.
Contents of the .debug_frame section:

 000c  CIE
  Version:   1
  Augmentation:  ""
  Code alignment factor: 1
  Data alignment factor: -4
  Return address column: 15

  DW_CFA_def_cfa: r14 ofs 0

0010 000c  FDE cie= pc=..0014

Contents of the .debug_info section:

  Compilation Unit @ offset 0x0:
   Length:0x28c (32-bit)
   Version:   2
   Abbrev Offset: 0x0
   Pointer Size:  4
 <0>: Abbrev Number: 1 (DW_TAG_compile_unit)
   DW_AT_producer: (indirect string, offset: 0x45): GNU C17 
8.2.1 20180814 -mcpu=v9 -gdwarf-2 -g -O2 
<10>   DW_AT_language: 12   (ANSI C99)
<11>   DW_AT_comp_dir: (indirect string, offset: 0x10b): 
/export/home/amandeep  
<15>   DW_AT_low_pc  : 0x0  
<19>   DW_AT_high_pc : 0x14 
<1d>   DW_AT_stmt_list   : 0x0  
 <1><21>: Abbrev Number: 2 (DW_TAG_base_type)
<22>   DW_AT_byte_size   : 4
<23>   DW_AT_encoding: 5(signed)
<24>   DW_AT_name: int  
 <1><28>: Abbrev Number: 3 (DW_TAG_base_type)
<29>   DW_AT_byte_size   : 4
<2a>   DW_AT_encoding: 7(unsigned

Re: [go-nuts] call of non-function C.testc

2018-09-14 Thread amandeep
It would be the same. Please see below.

-bash-3.2$ gcc --version
gcc (GCC) 8.2.1 20180814
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


On Friday, September 14, 2018 at 1:34:20 PM UTC-7, Ian Lance Taylor wrote:
>
> On Fri, Sep 14, 2018 at 1:40 AM,  > 
> wrote: 
> > 
> > oh yes, I am using gccgo. I configured gccgo from source. Below is the 
> go 
> > version output: 
> > go version go1.10.3 gccgo (GCC) 8.2.1 20180814 solaris/sparc 
>
> What version of GCC are you using?  What is the output of `gcc --version`? 
>
> 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] call of non-function C.testc

2018-09-14 Thread amandeep
oh yes, I am using gccgo. I configured gccgo from source. Below is the go 
version output:
*go version go1.10.3 gccgo (GCC) 8.2.1 20180814 solaris/sparc *

Following is the output of what is

-bash-3.2$ go build -x sol10.go
  
WORK=/tmp/go-build151901300
mkdir -p $WORK/b001/
cd $WORK
/usr/gnu/bin/gccgo -fsplit-stack -c -x c - || true
cd /export/home/amandeep
CGO_LDFLAGS='"-g" "-O2"' 
/usr/gnu/libexec/gcc/sparc-sun-solaris2.10/8.2.1/cgo -objdir $WORK/b001/ 
-importpath command-line-arguments -gccgo -- -I $WORK/b001/ -g -O2 
./sol10.go
# command-line-arguments
./sol10.go:15:5: call of non-function C.testc

As suggested, next I ran with -debug-gcc option:

-bash-3.2$ CGO_LDFLAGS='"-g" "-O2"' 
/usr/gnu/libexec/gcc/sparc-sun-solaris2.10/8.2.1/cgo -debug-gcc -objdir 
$WORK/b001/ -importpath command-line-arguments -gccgo -- -I $WORK/b001/ -g 
-O2 ./sol10.go 
$ gcc -E -dM -xc -I /b001/ -g -O2 - < /* for ptrdiff_t and size_t below */

/* Define intgo when compiling with GCC.  */
typedef ptrdiff_t intgo;

typedef struct { const char *p; intgo n; } _GoString_;
typedef struct { char *p; intgo n; intgo c; } _GoBytes_;
_GoString_ GoString(char *p);
_GoString_ GoStringN(char *p, int l);
_GoBytes_ GoBytes(void *p, int n);
char *CString(_GoString_);
void *CBytes(_GoBytes_);
void *_CMalloc(size_t);

__attribute__ ((unused))
static size_t _GoStringLen(_GoString_ s) { return s.n; }

__attribute__ ((unused))
static const char *_GoStringPtr(_GoString_ s) { return s.p; }
#line 3 "/export/home/amandeep/sol10.go"
 
#include 

void testc() {
printf("Hello cgo");
}

#line 1 "cgo-generated-wrapper"
EOF
#define __DBL_MIN_EXP__ (-1021)
#define __FLT32X_MAX_EXP__ 1024
#define _SYS_FEATURE_TESTS_H 
#define __UINT_LEAST16_MAX__ 0x
#define __ATOMIC_ACQUIRE 2
#define __FLT128_MAX_10_EXP__ 4932
#define __sun_attr___packed__ __attribute__((__packed__))
#define __FLT_MIN__ 1.1754943508222875079687365374568e-38F
#define __GCC_IEC_559_COMPLEX 2
#define __UINT_LEAST8_TYPE__ unsigned char
#define _T_WCHAR_ 
#define __INTMAX_C(c) c ## LL
#define __CHAR_BIT__ 8
#define __UINT8_MAX__ 0xff
#define __sun_attr___VPRINTFLIKE__(__n) __attribute__((__format__(printf, 
__n, 0)))
#define _FILEDEFED 
#define __WINT_MAX__ 0x7fffL
#define __FLT32_MIN_EXP__ (-125)
#define stderr (&__iob[2])
#define __ORDER_LITTLE_ENDIAN__ 1234
#define __SIZE_MAX__ 0xU
#define __WCHAR_MAX__ 0x7fffL
#define _LONG_LONG_ALIGNMENT 8
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
#define __DBL_DENORM_MIN__ 
((double)4.94065645841246544176568792868221372e-324L)
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
#define __GCC_ATOMIC_CHAR_LOCK_FREE 2
#define _OBP 
#define __GCC_IEC_559 2
#define __FLT32X_DECIMAL_DIG__ 17
#define _IOFBF 
#define __sun_attr___pure__ __attribute__((__pure__))
#define __FLT_EVAL_METHOD__ 0
#define __unix__ 1
#define __FLT64_DECIMAL_DIG__ 17
#define _XOPEN_VERSION 3
#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
#define __UINT_FAST64_MAX__ 0xULL
#define __SIG_ATOMIC_TYPE__ int
#define __DBL_MIN_10_EXP__ (-307)
#define __FINITE_MATH_ONLY__ 0
#define L_cuserid 9
#define ___sun_attr_inner(__a) __sun_attr_ ##__a
#define __sun_attr___noreturn__ __attribute__((__noreturn__))
#define __GNUC_PATCHLEVEL__ 1
#define __FLT32_HAS_DENORM__ 1
#define __UINT_FAST8_MAX__ 0xff
#define __has_include(STR) __has_include__(STR)
#define __size_t 
#define __DEC64_MAX_EXP__ 385
#define _WCHAR_T_DEFINED 
#define __INT8_C(c) c
#define __INT_LEAST8_WIDTH__ 8
#define sparc 1
#define __UINT_LEAST64_MAX__ 0xULL
#define __sun_attr__(__a) ___sun_attr_inner __a
#define __SHRT_MAX__ 0x7fff
#define __LDBL_MAX__ 1.18973149535723176508575932662800702e+4932L
#define __FLT64X_MAX_10_EXP__ 4932
#define __UINT_LEAST8_MAX__ 0xff
#define __GCC_ATOMIC_BOOL_LOCK_FREE 2
#define __FLT128_DENORM_MIN__ 
6.47517511943802511092443895822764655e-4966F128
#define __UINTMAX_TYPE__ long long unsigned int
#define __DEC32_EPSILON__ 1E-6DF
#define __FLT_EVAL_METHOD_TS_18661_3__ 0
#define __OPTIMIZE__ 1
#define putchar(x) putc((x), stdout)
#define __unix 1
#define __UINT32_MAX__ 0xU
#define __SIZE_T 
#define __LDBL_MAX_EXP__ 16384
#define __FLT128_MIN_EXP__ (-16381)
#define __WINT_MIN__ (-__WINT_MAX__ - 1)
#define __sun 1
#define __FLT128_MIN_10_EXP__ (-4931)
#define __INT_LEAST16_WIDTH__ 16
#define _SIZE_T_DEFINED_ 
#define __SCHAR_MAX__ 0x7f
#define _LONG_ALIGNMENT 4
#define __FLT128_MANT_DIG__ 113
#define __WCHAR_MIN__ (-__WCHAR_MAX__ - 1)
#define __INT64_C(c) c ## LL
#define _INT_ALIGNMENT 4
#define __DBL_DIG__ 15
#define __GCC_ATOMIC_POINTER_LOCK_FREE 2
#define __FLT64X_MANT_DIG__ 113
#define _SYS_CCOMPILE_H 
#define getchar() getc(stdin)
#define __SIZEOF_INT__ 4
#define __S

[go-nuts] call of non-function C.testc

2018-09-13 Thread amandeep
Trying to compile the following on Solaris 10 gives the error: call of 
non-function C.testc

package main

/* 
#include 

void testc() {
printf("Hello cgo");
}
*/
import "C"

func main() {
C.testc()
}

The output of go env is below:
bash-4.3$ go env 
GOARCH="sparc"
GOBIN=""
GOCACHE="/export/home/amandeep/.cache/go-build"
GOEXE=""
GOHOSTARCH="sparc"
GOHOSTOS="solaris"
GOOS="solaris"
GOPATH="/export/home/amandeep/go"
GORACE=""
GOROOT="/usr/gnu"
GOTMPDIR=""
GOTOOLDIR="/usr/gnu/libexec/gcc/sparc-sun-solaris2.10/8.2.1"
GCCGO="/usr/gnu/bin/gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -pthread -fmessage-length=0 
-fdebug-prefix-map=/tmp/go-build622699141=/tmp/go-build 
-gno-record-gcc-switches -funwind-tables"

How can we debug the issue? What am I missing? a simple go file (without 
cgo) compiles and runs just fine. Additionally, this runs just fine on 
Solaris 11 as well.


-- 
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] internal compilation error while compiling gccgo from source solaris 10

2018-08-27 Thread Amandeep Gautam
Hi Ian,
   Thank you so much for the help. Both of those options did not work. 
Somehow, the program was able to get buggy libmpfr. I think it might be 
because I am using /usr/ccs/bin/ld and that ld is giving preference to 
libraries in /usr/lib. 
  In my case, /usr/lib/libmpc.so.3 pointed to /opt/csw/lib/libmpc.so.3 and 
that is how it was reaching to the buggy libmpfr. I changed the symlink for 
mpc/mpfr/gmp libs to point to the libs I have installed and it worked.

On Saturday, August 25, 2018 at 10:25:39 AM UTC-7, Ian Lance Taylor wrote:
>
> On Fri, Aug 24, 2018 at 11:48 PM, Amandeep Gautam 
> > wrote: 
> > Hi Ian, 
> >I compiled GMP, MPFR and MPC from source. Next, I configured gcc with 
> > modified options: 
> > 
> > $srcdir/configure \ 
> > --prefix=$prefix \ 
> > --enable-languages=go \ 
> > --with-as=/opt/csw/gnu/as --with-gnu-as \ 
> > --with-ld=/usr/ccs/bin/ld --without-gnu-ld \ 
> > --with-gmp-include=/usr/gnu/gmp/include 
> --with-gmp-lib=/usr/gnu/gmp/lib 
> > \ 
> > --with-mpfr=/usr/gnu/mpfr --with-mpfr-include=/usr/gnu/mpfr/include 
> > --with-mpfr-lib=/usr/gnu/mpfr/lib \ 
> > --with-mpc=/usr/gnu/mpc \ 
> > --with-isl=/opt/csw --with-isl-include=/opt/csw/include 
> > --with-isl-lib=/opt/csw/lib \ 
> > --with-build-time-tools=/opt/csw/gnu \ 
> > --enable-multilib \ 
> > --enable-shared \ 
> > --enable-static \ 
> > --disable-nls \ 
> > --disable-libquadmath \ 
> > --disable-libssp \ 
> > --disable-lto \ 
> > --disable-libgomp 
> > 
> > The make step is still failing but, to my surprise, I found that it is 
> still 
> > able to find libmpfr.so.4 from the /opt/csw directory. I am guessing 
> that I 
> > am not configuring something correctly. Can you please look. 
>
> Maybe you need to set LD_LIBRARY_PATH to point to your newly built 
> libmpfr? 
>
> Another approach is to copy the mpfr sources into your GCC directory, 
> named exactly mpfr.  Then the GCC build will automatically use that 
> one. 
>
> Ian 
>
>
>
>
> > Output from GBD: 
> > 
> > -bash-3.2$ gdb /export/home/amandeep/gccgo-obj/./gcc/go1 
> > GNU gdb (GDB) 7.7 
> > Copyright (C) 2014 Free Software Foundation, Inc. 
> > License GPLv3+: GNU GPL version 3 or later 
> > <http://gnu.org/licenses/gpl.html> 
> > This is free software: you are free to change and redistribute it. 
> > There is NO WARRANTY, to the extent permitted by law.  Type "show 
> copying" 
> > and "show warranty" for details. 
> > This GDB was configured as "sparc-sun-solaris2.10". 
> > Type "show configuration" for configuration details. 
> > For bug reporting instructions, please see: 
> > <http://www.gnu.org/software/gdb/bugs/>. 
> > Find the GDB manual and other documentation resources online at: 
> > <http://www.gnu.org/software/gdb/documentation/>. 
> > For help, type "help". 
> > Type "apropos word" to search for commands related to "word"... 
> > Reading symbols from /export/home/amandeep/gccgo-obj/./gcc/go1...done. 
> > (gdb) run /export/home/amandeep/gccgo-src/libgo/go/fmt/doc.go 
> > /export/home/amandeep/gccgo-src/libgo/go/fmt/format.go 
> > /export/home/amandeep/gccgo-src/libgo/go/fmt/print.go 
> > /export/home/amandeep/gccgo-src/libgo/go/fmt/scan.go -quiet -dumpbase 
> doc.go 
> > -mcpu=v9 -auxbase-strip .libs/fmt.o -g -O2 -version -fgo-pkgpath=fmt 
> -fPIC 
> > -I . -L/export/home/amandeep/gccgo-obj/./gcc -o /var/tmp//ccBuuCrV. 
> > Starting program: /export/home/amandeep/gccgo-obj/gcc/go1 
> > /export/home/amandeep/gccgo-src/libgo/go/fmt/doc.go 
> > /export/home/amandeep/gccgo-src/libgo/go/fmt/format.go 
> > /export/home/amandeep/gccgo-src/libgo/go/fmt/print.go 
> > /export/home/amandeep/gccgo-src/libgo/go/fmt/scan.go -quiet -dumpbase 
> doc.go 
> > -mcpu=v9 -auxbase-strip .libs/fmt.o -g -O2 -version -fgo-pkgpath=fmt 
> -fPIC 
> > -I . -L/export/home/amandeep/gccgo-obj/./gcc -o /var/tmp//ccBuuCrV. 
> > [Thread debugging using libthread_db enabled] 
> > [New Thread 1 (LWP 1)] 
> > GNU Go (GCC) version 8.2.1 20180814 (sparc-sun-solaris2.10) 
> > compiled by GNU C version 8.2.1 20180814, GMP version 6.1.2, 
> MPFR 
> > version 4.0.1-p13, MPC version 1.1.0, isl version csw-0.18-GMP 
> > 
> > warning: MPFR header version 4.0.1-p13 differs from library version 
> 4.0.0. 
> > warning: MPC header version 1.1.0 differs from library version 1.0.2. 
> > GGC heuristics: --param ggc-min-expand=100 --param

Re: [go-nuts] internal compilation error while compiling gccgo from source solaris 10

2018-08-25 Thread Amandeep Gautam
Hi Ian,
   I compiled GMP, MPFR and MPC from source. Next, I configured gcc with 
modified options:

$srcdir/configure \
--prefix=$prefix \
--enable-languages=go \
--with-as=/opt/csw/gnu/as --with-gnu-as \
--with-ld=/usr/ccs/bin/ld --without-gnu-ld \
--with-gmp-include=/usr/gnu/gmp/include --with-gmp-lib=/usr/gnu/gmp/lib 
\
--with-mpfr=/usr/gnu/mpfr --with-mpfr-include=/usr/gnu/mpfr/include 
--with-mpfr-lib=/usr/gnu/mpfr/lib \
--with-mpc=/usr/gnu/mpc \
--with-isl=/opt/csw --with-isl-include=/opt/csw/include 
--with-isl-lib=/opt/csw/lib \
--with-build-time-tools=/opt/csw/gnu \
--enable-multilib \
--enable-shared \
--enable-static \
--disable-nls \
--disable-libquadmath \
--disable-libssp \
--disable-lto \
--disable-libgomp

The make step is still failing but, to my surprise, I found that it is 
still able to find libmpfr.so.4 from the /opt/csw directory. I am guessing 
that I am not configuring something correctly. Can you please look.

Output from GBD:

-bash-3.2$ gdb /export/home/amandeep/gccgo-obj/./gcc/go1
GNU gdb (GDB) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.10".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /export/home/amandeep/gccgo-obj/./gcc/go1...done.
(gdb) run /export/home/amandeep/gccgo-src/libgo/go/fmt/doc.go 
/export/home/amandeep/gccgo-src/libgo/go/fmt/format.go 
/export/home/amandeep/gccgo-src/libgo/go/fmt/print.go 
/export/home/amandeep/gccgo-src/libgo/go/fmt/scan.go -quiet -dumpbase 
doc.go -mcpu=v9 -auxbase-strip .libs/fmt.o -g -O2 -version -fgo-pkgpath=fmt 
-fPIC -I . -L/export/home/amandeep/gccgo-obj/./gcc -o /var/tmp//ccBuuCrV.
Starting program: /export/home/amandeep/gccgo-obj/gcc/go1 
/export/home/amandeep/gccgo-src/libgo/go/fmt/doc.go 
/export/home/amandeep/gccgo-src/libgo/go/fmt/format.go 
/export/home/amandeep/gccgo-src/libgo/go/fmt/print.go 
/export/home/amandeep/gccgo-src/libgo/go/fmt/scan.go -quiet -dumpbase 
doc.go -mcpu=v9 -auxbase-strip .libs/fmt.o -g -O2 -version -fgo-pkgpath=fmt 
-fPIC -I . -L/export/home/amandeep/gccgo-obj/./gcc -o /var/tmp//ccBuuCrV.
[Thread debugging using libthread_db enabled]
[New Thread 1 (LWP 1)]
GNU Go (GCC) version 8.2.1 20180814 (sparc-sun-solaris2.10)
compiled by GNU C version 8.2.1 20180814, GMP version 6.1.2, MPFR 
version 4.0.1-p13, MPC version 1.1.0, isl version csw-0.18-GMP

warning: MPFR header version 4.0.1-p13 differs from library version 4.0.0.
warning: MPC header version 1.1.0 differs from library version 1.0.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Go (GCC) version 8.2.1 20180814 (sparc-sun-solaris2.10)
compiled by GNU C version 8.2.1 20180814, GMP version 6.1.2, MPFR 
version 4.0.1-p13, MPC version 1.1.0, isl version csw-0.18-GMP

warning: MPFR header version 4.0.1-p13 differs from library version 4.0.0.
warning: MPC header version 1.1.0 differs from library version 1.0.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
/export/home/amandeep/gccgo-src/libgo/go/fmt/format.go:8:9: error: import 
file 'strconv' not found
  "strconv"
 ^
/export/home/amandeep/gccgo-src/libgo/go/fmt/format.go:9:14: error: import 
file 'unicode/utf8' not found
  "unicode/utf8"
  ^
*... and many more like this before terminating...*

/export/home/amandeep/gccgo-src/libgo/go/fmt/scan.go:688:52: error: 
expected integer, floating, complex, or string type
   s.errorString("unsigned integer overflow on token " + tok)
^

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1 (LWP 1)]
0xfbb8df24 in mpfr_init2 () from */opt/csw/lib/sparcv8/libmpfr.so.4*
(gdb) bt
#0  0xfbb8df24 in mpfr_init2 () from /opt/csw/lib/sparcv8/libmpfr.so.4
#1  0xff1d8bac in mpc_init2 () from /usr/lib/libmpc.so.3
#2  0x001c5500 in Numeric_constant::check_complex_type (this=0xffbff208, 
type=0x10944c8, issue_error=, location=...)
at 
/export/home/amandeep/gccgo-src/gcc/go/gofrontend/expressions.cc:16745
#3  0x001c588c in Numeric_constant::set_type (this=0xffbff208, 
type=0x11f4f78, issue_error=, loc=...) at 
/export/home/amandeep/gccgo-src/gcc/go/gofrontend/types.h:751
#4  0x001c5944 in Integer_expression::

Re: [go-nuts] internal compilation error while compiling gccgo from source solaris 10

2018-08-23 Thread Amandeep Gautam
Running inside the gdb worked. Seems like a problem with libmpfr. Will try 
compiling it from source.
Following is the end of the GDB output:

/export/home/amandeep/gccgo-src/libgo/go/fmt/scan.go:658:43: error: 
expected integer, floating, complex, or string type
   s.errorString("integer overflow on token " + tok)
   ^
/export/home/amandeep/gccgo-src/libgo/go/fmt/scan.go:688:52: error: 
expected integer, floating, complex, or string type
   s.errorString("unsigned integer overflow on token " + tok)
^

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1 (LWP 1)]
0xfbb8df24 in mpfr_init2 () from /opt/csw/lib/sparcv8/libmpfr.so.4
(gdb) bt
#0  0xfbb8df24 in mpfr_init2 () from /opt/csw/lib/sparcv8/libmpfr.so.4
#1  0xff1d8bac in mpc_init2 () from /usr/lib/libmpc.so.3
#2  0x001c5500 in Numeric_constant::check_complex_type (this=0xffbff0e8, 
type=0x1094488, issue_error=, location=...)
    at 
/export/home/amandeep/gccgo-src/gcc/go/gofrontend/expressions.cc:16745
#3  0x001c588c in Numeric_constant::set_type (this=0xffbff0e8, 
type=0x11f4f38, issue_error=, loc=...)
at /export/home/amandeep/gccgo-src/gcc/go/gofrontend/types.h:751
#4  0x001c5944 in Integer_expression::do_check_types (this=0x11f50a0) at 
/export/home/amandeep/gccgo-src/gcc/go/gofrontend/expressions.h:535
#5  0x001e7d04 in check_types (gogo=, this=) 
at /export/home/amandeep/gccgo-src/gcc/go/gofrontend/expressions.h:920
#6  Check_types_traverse::expression (this=, expr=0x123ba88) 
at /export/home/amandeep/gccgo-src/gcc/go/gofrontend/gogo.cc:3306
#7  0x001b3fc8 in Expression::traverse (pexpr=0x123ba88, 
traverse=0xffbff6d4) at 
/export/home/amandeep/gccgo-src/gcc/go/gofrontend/expressions.cc:45
#8  0x0022eb8c in Statement::traverse (this=0x123ba78, block=0x123c128, 
pindex=0xffbff294, traverse=0xffbff6d4)
at /export/home/amandeep/gccgo-src/gcc/go/gofrontend/statements.cc:54
#9  0x001ea9f0 in Block::traverse (this=0x123c128, traverse=0xffbff6d4) at 
/export/home/amandeep/gccgo-src/gcc/go/gofrontend/gogo.cc:6063
#10 0x0022eb8c in Statement::traverse (this=0x123ba98, block=0x11f5078, 
pindex=0xffbff35c, traverse=0xffbff6d4)
at /export/home/amandeep/gccgo-src/gcc/go/gofrontend/statements.cc:54
#11 0x001ea9f0 in Block::traverse (this=0x11f5078, traverse=0xffbff6d4) at 
/export/home/amandeep/gccgo-src/gcc/go/gofrontend/gogo.cc:6063
#12 0x0022df60 in If_statement::do_traverse (this=0x11f6370, 
traverse=0xffbff6d4) at 
/export/home/amandeep/gccgo-src/gcc/go/gofrontend/statements.cc:84
#13 0x0022eb8c in Statement::traverse (this=0x11f6370, block=0x11f5028, 
pindex=0xffbff484, traverse=0xffbff6d4)
at /export/home/amandeep/gccgo-src/gcc/go/gofrontend/statements.cc:54
#14 0x001ea9f0 in Block::traverse (this=0x11f5028, traverse=0xffbff6d4) at 
/export/home/amandeep/gccgo-src/gcc/go/gofrontend/gogo.cc:6063
#15 0x0022eb8c in Statement::traverse (this=0x11f6390, block=0x11f4f60, 
pindex=0xffbff54c, traverse=0xffbff6d4)
at /export/home/amandeep/gccgo-src/gcc/go/gofrontend/statements.cc:54
#16 0x001ea9f0 in Block::traverse (this=0x11f4f60, traverse=0xffbff6d4) at 
/export/home/amandeep/gccgo-src/gcc/go/gofrontend/gogo.cc:6063
#17 0x001eac80 in Function::traverse (this=0x11f6a88, traverse=0xffbff6d4) 
at /export/home/amandeep/gccgo-src/gcc/go/gofrontend/gogo.cc:5135
#18 0x001ec6f0 in Bindings::traverse (this=0x10b4f60, traverse=0xffbff6d4, 
is_global=) at 
/export/home/amandeep/gccgo-src/gcc/go/gofrontend/gogo.h:2584
#19 0x001eca38 in Gogo::traverse (this=0x10f03f8, traverse=0xffbff6d4) at 
/export/home/amandeep/gccgo-src/gcc/go/gofrontend/gogo.h:3200
#20 0x001ecd2c in Gogo::check_types (this=0x10f03f8) at 
/export/home/amandeep/gccgo-src/gcc/go/gofrontend/gogo.cc:3316
#21 0x001e7700 in go_parse_input_files (filenames=0x10cf468, 
filename_count=4, only_check_syntax=)
at /export/home/amandeep/gccgo-src/gcc/go/gofrontend/go.cc:136
#22 0x001e2480 in go_langhook_parse_file () at 
/export/home/amandeep/gccgo-src/gcc/go/go-lang.c:329
#23 0x006b97d4 in compile_file () at 
/export/home/amandeep/gccgo-src/gcc/toplev.c:455
#24 0x00e1c9f4 in toplev::main(int, char**) () at ./insn-modes-inline.h:38
#25 0x00e1e1e4 in main (argc=21, argv=0xffbffa44) at 
/export/home/amandeep/gccgo-src/gcc/main.c:39

On Thursday, August 23, 2018 at 2:25:38 PM UTC-7, Ian Lance Taylor wrote:
>
> On Thu, Aug 23, 2018 at 2:14 PM, Amandeep Gautam 
> > wrote: 
> > 
> > /export/home/amandeep/gccgo-obj/./gcc/go1 
> > /export/home/amandeep/gccgo-src/libgo/go/fmt/doc.go 
> > /export/home/amandeep/gccgo-src/libgo/go/fmt/format.go 
> > /export/home/amandeep/gccgo-src/libgo/go/fmt/print.go 
> > /export/home/amandeep/gccgo-src/libgo/go/fmt/scan.go -quiet -dumpbase 
> doc.go 
> > -mcpu=v9 -auxbase-strip .libs/fmt.o -g -O2 -version -fgo-pkgpath=fmt 
> -fPIC 
> > -I . -L/export/home/amandeep/gccgo

Re: [go-nuts] internal compilation error while compiling gccgo from source solaris 10

2018-08-23 Thread Amandeep Gautam
Thanks. I did do that befor but thought you meant different. I ran the 
following:

/export/home/amandeep/gccgo-obj/./gcc/gccgo 
-B/export/home/amandeep/gccgo-obj/./gcc/ 
-B/usr/gnu/sparc-sun-solaris2.10/bin/ -B/usr/gnu/sparc-sun-solaris2.10/lib/ 
-isystem /usr/gnu/sparc-sun-solaris2.10/include -isystem 
/usr/gnu/sparc-sun-solaris2.10/sys-include -O2 -g -I . -c -fgo-pkgpath=fmt 
/export/home/amandeep/gccgo-src/libgo/go/fmt/doc.go 
/export/home/amandeep/gccgo-src/libgo/go/fmt/format.go 
/export/home/amandeep/gccgo-src/libgo/go/fmt/print.go 
/export/home/amandeep/gccgo-src/libgo/go/fmt/scan.go  -fPIC -o .libs/fmt.o

and got:

Reading specs from /export/home/amandeep/gccgo-obj/./gcc/specs
COLLECT_GCC=/export/home/amandeep/gccgo-obj/./gcc/gccgo
Target: sparc-sun-solaris2.10
Configured with: /export/home/amandeep/gccgo-src/configure 
--prefix=/usr/gnu --enable-languages=go --with-as=/opt/csw/gnu/as 
--with-gnu-as --with-ld=/usr/ccs/bin/ld --without-gnu-ld 
--with-gmp-include=/opt/csw/include --with-gmp-lib=/opt/csw/lib 
--with-mpfr=/opt/csw --with-mpfr-include=/opt/csw/include 
--with-mpfr-lib=/opt/csw/lib --with-mpc=/opt/csw --with-isl=/opt/csw 
--with-isl-include=/opt/csw/include --with-isl-lib=/opt/csw/lib 
--with-build-time-tools=/opt/csw/gnu --enable-multilib --enable-shared 
--enable-static --disable-nls --disable-libquadmath --disable-libssp 
--disable-lto --disable-libgomp
Thread model: posix
gcc version 8.2.1 20180814 (GCC) 
COLLECT_GCC_OPTIONS='-B' '/export/home/amandeep/gccgo-obj/./gcc/' '-B' 
'/usr/gnu/sparc-sun-solaris2.10/bin/' '-B' 
'/usr/gnu/sparc-sun-solaris2.10/lib/' '-isystem' 
'/usr/gnu/sparc-sun-solaris2.10/include' '-isystem' 
'/usr/gnu/sparc-sun-solaris2.10/sys-include' '-v' '-O2' '-g' '-I' '.' '-c' 
'-fgo-pkgpath=fmt' '-fPIC' '-o' '.libs/fmt.o' '-shared-libgcc' '-mcpu=v9'
 /export/home/amandeep/gccgo-obj/./gcc/go1 
/export/home/amandeep/gccgo-src/libgo/go/fmt/doc.go 
/export/home/amandeep/gccgo-src/libgo/go/fmt/format.go 
/export/home/amandeep/gccgo-src/libgo/go/fmt/print.go 
/export/home/amandeep/gccgo-src/libgo/go/fmt/scan.go -quiet -dumpbase 
doc.go -mcpu=v9 -auxbase-strip .libs/fmt.o -g -O2 -version -fgo-pkgpath=fmt 
-fPIC -I . -L/export/home/amandeep/gccgo-obj/./gcc -o /var/tmp//ccmxS20e.s
GNU Go (GCC) version 8.2.1 20180814 (sparc-sun-solaris2.10)
compiled by GNU C version 8.2.1 20180814, GMP version 6.1.2, MPFR 
version 4.0.0, MPC version 1.0.2, isl version csw-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Go (GCC) version 8.2.1 20180814 (sparc-sun-solaris2.10)
compiled by GNU C version 8.2.1 20180814, GMP version 6.1.2, MPFR 
version 4.0.0, MPC version 1.0.2, isl version csw-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
/export/home/amandeep/gccgo-src/libgo/go/fmt/format.go:8:9: error: import 
file 'strconv' not found
  "strconv"
 ^
/export/home/amandeep/gccgo-src/libgo/go/fmt/format.go:9:14: error: import 
file 'unicode/utf8' not found
  "unicode/utf8"
  ^
/export/home/amandeep/gccgo-src/libgo/go/fmt/print.go:8:8: error: import 
file 'errors' not found
  "errors"
    ^
/export/home/amandeep/gccgo-src/libgo/go/fmt/print.go:9:4: error: import 
file 'io' not found
  "io"

* and many more like this before ending as follows:*

/export/home/amandeep/gccgo-src/libgo/go/fmt/scan.go:688:52: error: 
expected integer, floating, complex, or string type
   s.errorString("unsigned integer overflow on token " + tok)
^
gccgo: internal compiler error: Segmentation Fault signal terminated 
program go1
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.

Before running this, I have already exported the paths as I did in the 
script in the first post. These are below:

export PATH=/opt/csw/bin:/usr/sbin:$PATH:/usr/sfw/bin:/usr/ccs/bin
export LD_OPTIONS='-R/opt/csw/lib'
export M4=/opt/csw/bin/gm4

As suggested, next I ran:

/export/home/amandeep/gccgo-obj/./gcc/go1 
/export/home/amandeep/gccgo-src/libgo/go/fmt/doc.go 
/export/home/amandeep/gccgo-src/libgo/go/fmt/format.go 
/export/home/amandeep/gccgo-src/libgo/go/fmt/print.go 
/export/home/amandeep/gccgo-src/libgo/go/fmt/scan.go -quiet -dumpbase 
doc.go -mcpu=v9 -auxbase-strip .libs/fmt.o -g -O2 -version -fgo-pkgpath=fmt 
-fPIC -I . -L/export/home/amandeep/gccgo-obj/./gcc -o /var/tmp//ccmxS20e.s

and I got:

GNU Go (GCC) version 8.2.1 20180814 (sparc-sun-solaris2.10)
compiled by GNU C version 8.2.1 20180814, GMP version 6.1.2, MPFR 
version 4.0.0, MPC version 1.0.2, isl version csw-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Go (GCC) version 8.2.1 20180814 (sparc-sun-solaris2.10)
compiled by GNU C version 8.2.1 20180814, GMP version 6.1.2, MPFR 
version 4.0.0, MPC version 1.0.2, isl vers

Re: [go-nuts] internal compilation error while compiling gccgo from source solaris 10

2018-08-23 Thread Amandeep Gautam
Hi Ian,
  I ran the following after changing directory to 
/export/home/amandeep/gccgo-obj/sparc-sun-solaris2.10/libgo/:

files=`echo /export/home/amandeep/gccgo-src/libgo/go/fmt/doc.go 
/export/home/amandeep/gccgo-src/libgo/go/fmt/format.go 
/export/home/amandeep/gccgo-src/libgo/go/fmt/print.go 
/export/home/amandeep/gccgo-src/libgo/go/fmt/scan.go errors.gox io.gox 
math.gox os.gox reflect.gox strconv.gox sync.gox unicode/utf8.gox | sed -e 
's/[^ ]*\.gox//g' -e 's/[^ ]*\.dep//'`; /bin/bash ./libtool --tag GO 
--mode=compile --verbose /export/home/amandeep/gccgo-obj/./gcc/gccgo 
-B/export/home/amandeep/gccgo-obj/./gcc/ 
-B/usr/gnu/sparc-sun-solaris2.10/bin/ -B/usr/gnu/sparc-sun-solaris2.10/lib/ 
-isystem /usr/gnu/sparc-sun-solaris2.10/include -isystem 
/usr/gnu/sparc-sun-solaris2.10/sys-include   -O2 -g -I . -c 
-fgo-pkgpath=`echo fmt.lo | sed -e 's/.lo$//' -e 
's|golang_org|vendor/golang_org|'`  -o fmt.lo $files

I still get the same compilation error:

go1: internal compiler error: Segmentation Fault
0x6b9757 crash_signal
/export/home/amandeep/gccgo-src/gcc/toplev.c:325
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

and did not get any more output using the verbose option. What should have 
been done differently?

On Monday, August 20, 2018 at 6:41:54 PM UTC-7, Ian Lance Taylor wrote:
>
> On Sun, Aug 19, 2018 at 9:39 PM, Amandeep Gautam 
> > wrote: 
>
> > gmake[3]: Entering directory 
> > '/export/home/amandeep/gccgo-obj/sparc-sun-solaris2.10/libgo' 
> > gmake[4]: Entering directory 
> > '/export/home/amandeep/gccgo-obj/sparc-sun-solaris2.10/libgo' 
> > /opt/csw/bin/gmkdir -p .; files=`echo 
> > /export/home/amandeep/gccgo-src/libgo/go/fmt/doc.go 
> > /export/home/amandeep/gccgo-src/libgo/go/fmt/format.go 
> > /export/home/amandeep/gccgo-src/libgo/go/fmt/print.go 
> > /export/home/amandeep/gccgo-src/libgo/go/fmt/scan.go errors.gox io.gox 
> > math.gox os.gox reflect.gox strconv.gox sync.gox unicode/utf8.gox | sed 
> -e 
> > 's/[^ ]*\.gox//g' -e 's/[^ ]*\.dep//'`; /bin/bash ./libtool --tag GO 
> > --mode=compile /export/home/amandeep/gccgo-obj/./gcc/gccgo 
> > -B/export/home/amandeep/gccgo-obj/./gcc/ 
> > -B/usr/gnu/sparc-sun-solaris2.10/bin/ 
> -B/usr/gnu/sparc-sun-solaris2.10/lib/ 
> > -isystem /usr/gnu/sparc-sun-solaris2.10/include -isystem 
> > /usr/gnu/sparc-sun-solaris2.10/sys-include   -O2 -g -I . -c 
> > -fgo-pkgpath=`echo fmt.lo | sed -e 's/.lo$//' -e 
> > 's|golang_org|vendor/golang_org|'`  -o fmt.lo $files 
> > libtool: compile:  /export/home/amandeep/gccgo-obj/./gcc/gccgo 
> > -B/export/home/amandeep/gccgo-obj/./gcc/ 
> > -B/usr/gnu/sparc-sun-solaris2.10/bin/ 
> -B/usr/gnu/sparc-sun-solaris2.10/lib/ 
> > -isystem /usr/gnu/sparc-sun-solaris2.10/include -isystem 
> > /usr/gnu/sparc-sun-solaris2.10/sys-include -O2 -g -I . -c 
> -fgo-pkgpath=fmt 
> > /export/home/amandeep/gccgo-src/libgo/go/fmt/doc.go 
> > /export/home/amandeep/gccgo-src/libgo/go/fmt/format.go 
> > /export/home/amandeep/gccgo-src/libgo/go/fmt/print.go 
> > /export/home/amandeep/gccgo-src/libgo/go/fmt/scan.go  -fPIC -o 
> .libs/fmt.o 
> > go1: internal compiler error: Segmentation Fault 
> > 0x6b9757 crash_signal 
> > /export/home/amandeep/gccgo-src/gcc/toplev.c:325 
> > Please submit a full bug report, 
> > with preprocessed source if appropriate. 
> > Please include the complete backtrace with any bug report. 
> > See <https://gcc.gnu.org/bugs/> for instructions. 
> > gmake[4]: *** [Makefile:3324: fmt.lo] Error 1 
>
>
> Thanks.  Unfortunately, I don't know what could be causing this. 
> Everything looks fine, except that the compiler is crashing.  I'm not 
> seeing this on Solaris 11.  I think you will have to debug the 
> compiler.  To see more about what is happening, run the "compile:" 
> command by itself.  It should crash in the same way.  Then run it with 
> the -v option to see how the go1 program is being run.  Running the 
> go1 program with those arguments should crash.  That is what you need 
> to debug; presumably there is a NULL pointer dereference or something. 
>
> 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.


[go-nuts] internal compilation error while compiling gccgo from source solaris 10

2018-08-19 Thread Amandeep Gautam
I have been trying to install GCCGO on Solaris 10 with the following 
script: 

dir=/export/home/amandeep
srcdir=$dir/gccgo-src
objdir=$dir/gccgo-obj
prefix=/usr/gnu


# Create Directory
mkdir -p $objdir
sudo mkdir -p $prefix


# Exports
export PATH=/opt/csw/bin:/usr/sbin:$PATH:/usr/sfw/bin:/usr/ccs/bin
export LD_OPTIONS='-R/opt/csw/lib'


export M4=/opt/csw/bin/gm4
# Make
cd $objdir
 $srcdir/configure \
--prefix=$prefix \
--enable-languages=go \
--with-as=/opt/csw/gnu/as --with-gnu-as \
--with-ld=/usr/ccs/bin/ld --without-gnu-ld \
--with-gmp-include=/opt/csw/include --with-gmp-lib=/opt/csw/lib \
--with-mpfr=/opt/csw --with-mpfr-include=/opt/csw/include --with-mpfr-
lib=/opt/csw/lib \
--with-mpc=/opt/csw \
--with-isl=/opt/csw --with-isl-include=/opt/csw/include --with-isl-lib=
/opt/csw/lib \
--with-build-time-tools=/opt/csw/gnu \
--enable-multilib \
--enable-shared \
--enable-static \
--disable-nls \
--disable-libquadmath \
--disable-libssp \
--disable-lto \
--disable-libgomp


sudo gmake -j12
sudo gmake install


In the make step, the compiler bails out with following message :

go1: internal compiler error: Segmentation Fault
0x6b9757 crash_signal
/export/home/amandeep/gccgo-src/gcc/toplev.c:325
Please submit a full bug report,

I got gcc using the following:

svn co svn://gcc.gnu.org/svn/gcc/branches/gcc-8-branch 
<http://gcc.gnu.org/svn/gcc/branches/gcc-6-branch> gccgo-src 

I have tried using gcc-4.9 and gcc-5.5, but both gave the same error 
message (I did so because the compiler existing might have a message). I 
have configured all the dependencies from CSW site. Have I configured this 
correctly and doing things right? Is there a workaround for this? Should I 
try something else because filing a bug and waiting for it to resolve might 
take longer?

Let me know if you need any other information.


-- 
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.


[go-nuts] unrecognized import paths error while using go get

2018-08-14 Thread Amandeep Gautam
Hi,
   I installed gccgo on Solaris 11.3 using: sudo /opt/csw/bin/pkgutil -y -i 
gcc5core

Below is the output of go-5.5 env:

amandeep@s113ldom1:~$ go-5.5 env
GOARCH="sparc"
GOBIN=""
GOCHAR=""
GOEXE=""
GOHOSTARCH="sparc"
GOHOSTOS="solaris"
GOOS="solaris"
GOPATH="/home/amandeep/"
GORACE=""
GOROOT="/opt/csw"
GOTOOLDIR="/opt/csw/libexec/gcc/sparc-sun-solaris2.10/5.5.0"
CC="/opt/csw/bin/gcc-5.5"
GOGCCFLAGS="-fPIC -fmessage-length=0"
CXX="/opt/csw/bin/g++-5.5"
CGO_ENABLED="0"

I get unrecognized path error while trying to get a package:

amandeep@s113ldom1:~$ go-5.5 get github.com/dgrijalva/jwt-go
package bytes: unrecognized import path "bytes"
package crypto: unrecognized import path "crypto"
package crypto/ecdsa: unrecognized import path "crypto/ecdsa"
package crypto/hmac: unrecognized import path "crypto/hmac"
package crypto/rand: unrecognized import path "crypto/rand"
package crypto/rsa: unrecognized import path "crypto/rsa"
package crypto/subtle: unrecognized import path "crypto/subtle"
package crypto/x509: unrecognized import path "crypto/x509"
package encoding/base64: unrecognized import path "encoding/base64"
package encoding/json: unrecognized import path "encoding/json"
package encoding/pem: unrecognized import path "encoding/pem"
package errors: unrecognized import path "errors"
package fmt: unrecognized import path "fmt"
package math/big: unrecognized import path "math/big"
package runtime: unrecognized import path "runtime"
package strings: unrecognized import path "strings"
package sync: unrecognized import path "sync"
package time: unrecognized import path "time"

Most of the other resources online suggest that it might be because of 
inappropriately set GOROOT, but I haven't modified it.

After a little bit of digging I found that the .gox files are located in : 
/opt/csw/lib/go/5.5.0/sparc-sun-solaris2.10/
For example, bytes.gox lives at 
/opt/csw/lib/go/5.5.0/sparc-sun-solaris2.10/bytes.gox

Not sure what should be the correct settings here. Any suggestion 
appreciated.

-- 
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] Html is not parsing while parsing a template to send email

2018-05-04 Thread Amandeep Kaur

Hi, Jakob Borg

Thanks for ypur reply to the post. The solution you have provided can not 
be implemented on my system. I have provided a small sample of my code 
structure. Please take a look

type EmailTemplate struct{
BookingDetails string
}

type EmailRequest struct{
EmailTo  string
EmailBody  string
}

// get saved html with tokens from database
notificationTemplate, errVal := merchantDb.GetNotificationTemplate()
request := EmailRequest{
"t...@example.com", 
notificationTemplate.Content,
}
templateData.BookingDetails += 
"Industry"+industry.IndustryName+""

request.EmailSend(templateData)


func (request *EmailRequest) EmailSend(notificationTemplateData 
interface{}) (bool, error) {
body, errParse := ParseTemplate(request.EmailBody, 
notificationTemplateData)
//email sending code here 
}

func ParseTemplate(templateHtml string, data interface{}) (string, 
error) {
var body string
t, err := template.New("my_template").Parse(templateHtml)
if err != nil {
return body, err
}
buf := new(bytes.Buffer)

if err = t.Execute(buf, data); err != nil {
return body, err
}
body = buf.String()
return body, nil
}

Where templateHtml is the email body with tokens and data is the interface 
holding dynamic values for these tokens.
When I use ParseTemplate function to parse tokens as string values then it 
works fine. 
But if I have to parse html in one of my tokens then it parses html as 
string and in email displays html as string.

How ever If I try to make assertion on it from interface to template.HTML, 
it gives me error: 
cannot convert notificationTemplateData (type interface {}) to type 
"html/template".HTML: need type assertion
On Friday, May 4, 2018 at 2:18:51 PM UTC+5:30, Jakob Borg wrote:
>
> Hi, 
>
> Your post is a bit confusing and I think you may be using the word "parse" 
> in the opposite of it its common meaning. However, if you want to pass a 
> HTML fragment through a HTML template and have it not be escaped, look at 
> the template.HTML type: https://golang.org/pkg/html/template/#HTML
>
> //jb
>
> On 4 May 2018, at 10:42, Amandeep Kaur <amandeep...@gmail.com 
> > wrote:
>
> Hello,
>
> I am working on a SAAS based project for which I need to send emails to 
> different clients on different events. 
>
> I am using email templates which use tokens (in format {{.TOKENNAME}}) 
> that are made dynamic while sending emails. Now these token are parsed by 
> using "html/template" package. 
>
> following is the custom function that I have made to parse these tokens 
> into email body.
>
> func ParseTemplate(templateHtml string, data interface{}) (string, error) {
> var body string
> t, err := template.New("my_template").Parse(templateHtml)
> if err != nil {
> return body, err
> }
> buf := new(bytes.Buffer)
> 
> if err = t.Execute(buf, data); err != nil {
> return body, err
> }
> body = buf.String()
> return body, nil
> }
>
> Where templateHtml is the email body with tokens and data is the interface 
> holding dynamic values for these tokens. When I use ParseTemplate function 
> to parse tokens as string values then it works fine. But if I have to parse 
> html in one of my tokens then it parses html as string and in email 
> displays html as string.
>
> Can anybody tell me what should I do to parse html in ParseTemplate 
> function??
>
> Thanks!
>
> -- 
> 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...@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.


[go-nuts] Html is not parsing while parsing a template to send email

2018-05-04 Thread Amandeep Kaur
Hello,

I am working on a SAAS based project for which I need to send emails to 
different clients on different events. 

I am using email templates which use tokens (in format {{.TOKENNAME}}) that 
are made dynamic while sending emails. Now these token are parsed by using 
"html/template" package. 

following is the custom function that I have made to parse these tokens 
into email body.

func ParseTemplate(templateHtml string, data interface{}) (string, error) {
var body string
t, err := template.New("my_template").Parse(templateHtml)
if err != nil {
return body, err
}
buf := new(bytes.Buffer)

if err = t.Execute(buf, data); err != nil {
return body, err
}
body = buf.String()
return body, nil
}

Where templateHtml is the email body with tokens and data is the interface 
holding dynamic values for these tokens. When I use ParseTemplate function 
to parse tokens as string values then it works fine. But if I have to parse 
html in one of my tokens then it parses html as string and in email 
displays html as string.

Can anybody tell me what should I do to parse html in ParseTemplate 
function??

Thanks!

-- 
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.


[go-nuts] Pdeathsig alternate for other operating systems

2018-02-12 Thread Amandeep Gautam
I am writing a process monitoring solution in go for AIX. I would like to 
signal the child process when the parent dies so that it does not become 
orphaned. In linux, one can set PdeathSig 
(https://golang.org/pkg/syscall/#SysProcAttr) and Go will take care of the 
rest. However this attribute is absent for other operating system, like 
AIX. Can someone provide pointers on how this can be achieved?

-- 
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.


[go-nuts] Email sent via command line is not delivered in Golang

2018-01-24 Thread Amandeep Kaur




I am sending emails in one of my projects through command line. The project 
back end is written in Golang. I am using following code to send emails:



package utils


import(
"bytes"
"html/template"
"os/exec"
"fmt"
)

type EmailRequest struct{
EmailTo  string
EmailSubject string
EmailBodystring
}

func (request *EmailRequest) EmailSend(notificationTemplateData 
interface{}) (bool, error) {
subject, errParse := ParseTemplate(request.EmailSubject, 
notificationTemplateData)
body, errParse:= ParseTemplate(request.EmailBody, 
notificationTemplateData)
if errParse != nil{
return false, errParse
}
err := ExecuteMailCommand("mail -s \"$(echo \" "+subject+" \nMIME-version: 
1.0;\nContent-Type: text/html;charset=\"UTF-8\";\n\")\"  "+request.EmailTo, 
body)
if err != nil {
return false, err
}

return true, nil
}


func ParseTemplate(templateHtml string, data interface{}) (string, error) {
var body string
t, err := template.New("test").Parse(templateHtml)
if err != nil {
return body, err
}
buf := new(bytes.Buffer)

if err = t.Execute(buf, data); err != nil {
return body, err
}
body = buf.String()
return body, nil
}

   func ExecuteMailCommand(command string, body string) error {
cmd := exec.Command("sh", "-c", command)
cmd.Stdin = bytes.NewBufferString(body)

stdout, err := cmd.CombinedOutput()
if err != nil {
fmt.Printf("%v\n", err)
return err
}

fmt.Printf("%s\n", stdout)
return nil
}


But while sending email through this code, strange thing is happening. 
Sometimes the email is delivered immediately. But sometimes it is not 
delivered even upto somehours. The server is running on AWS.

I am not getting the reason why it is behaving like this. Do I need to set 
some server mail configurations or there is some problem in the code ?/

Thanks!

-- 
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.


[go-nuts] Is there an equivalent of telldir in go. If not what are the alternatives?

2018-01-10 Thread Amandeep Gautam
Is there a equivalent of telldir in golang which can page reading of a 
directory.
Just using filepath.walk would be inefficient for large file systems.

>From one of the answers to this question
https://stackoverflow.com/questions/39583522/how-do-i-use-seekdir-telldir-in-golang

it looks like there is nothing for this use case, which brings me to my 
next question: Any ideas about how to go about dealing such use case.

-- 
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.


[go-nuts] Client and server stub not generated for grpc-go

2018-01-04 Thread Amandeep Gautam
I am trying to write a grpc server in go but am unable get the generated 
client and server stub in the file generated by plugin.
Here is the paste of the file generated: https://pastebin.com/kfi99MxK

>From what I have researched, it is because of faulty protobuf installation 
but I am not sure what is exactly wrong and how to debug the root cause.

Any help is appreciated.

-- 
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] gRPC go on AIX

2017-12-21 Thread Amandeep Gautam
I am using precompiled binaries for AIX. But will keep your suggestion in 
mind.
For now it was fixed by installing ca certificates.

On Thursday, December 21, 2017 at 3:12:50 PM UTC-8, Ian Lance Taylor wrote:
>
> On Thu, Dec 21, 2017 at 1:43 PM,   
> wrote: 
> > 
> > Can someone help me to set up gRPC go on AIX running on a Power 8. I 
> > tried installing using go get -u google.golang.org/grpc 
> > (https://grpc.io/docs/quickstart/go.html#prerequisites), but it fails 
> with 
> > following: 
> > 
> > Fetching https://google.golang.org/grpc?go-get=1 
> > https fetch failed: Get https://google.golang.org/grpc?go-get=1: x509: 
> > failed to load system roots and no roots provided 
> > package google.golang.org/grpc: unrecognized import path 
> > "google.golang.org/grpc" (https fetch: Get 
> > https://google.golang.org/grpc?go-get=1: x509: failed to load system 
> roots 
> > and no roots provided) 
> > 
> > bash-4.4# go version 
> > go version go1.8.1 gccgo (GCC) 7.2.0 aix/ppc 
> > 
> > Any pointers would be helpful. 
>
> I believe that particular problem is fixed on GCC trunk by 
> https://golang.org/cl/37952. 
>
> In general as the AIX port is a work in progress I recommend using GCC 
> trunk, not GCC 7. 
>
> 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.


[go-nuts] Re: Update Mongodb fields with omitempty flag in Golang structure

2017-11-10 Thread Amandeep Kaur
Thanks @Diego Medina  It worked for me.

On Thursday, November 9, 2017 at 12:19:14 AM UTC+5:30, Diego Medina wrote:
>
> replied on the mgo list 
>
> https://groups.google.com/d/topic/mgo-users/F3LbWdyPGDc/discussion
>
> (pasted here to save a click)
>
> Hi,
>
> > the checkbox is unchecked and form is submitted to save. Now as I have 
> applied "omitempty" 
>
> if the checkbox is unchecked, your client side code should send "false" to 
> the go server, so omitempty is not applied because it is not empty, it is 
> false, so saving it to mongo will actually update the field.
>
> for truly optional fields, what I do is, declare the fields as pointers to 
> the type, so, you would have
>
> type Coupon struct {
> Id   *int`json:"id,omitempty" bson:"_id,omitempty"`
> Name *string `json:"name,omitempty" bson:"name,omitempty"`
> Code *string `json:"code,omitempty" bson:"code,omitempty"`
> Description  *string `json:"description,omitempty" 
> bson:"description,omitempty"`
> Status   *bool   `json:"status" bson:"status"`// I assume this 
> is also optional
> MaxUsageLimit*int`json:"max_usage_limit,omitempty" 
> bson:"max_usage_limit,omitempty"`
> SingleUsePerUser *bool   `json:"single_use_per_user,omitempty" 
> bson:"single_use_per_user,omitempty"`
> }
>
>
> the bson/json Un/marshaller will then omit the values that are nil 
> pointers, so now yo ucan tell the difference between a false checkbox, and 
> a REST POST that did not include the field at all
>
> Hope this helps.
>
> Diego
>
> On Wednesday, November 8, 2017 at 12:46:39 AM UTC-5, Amandeep Kaur wrote:
>>
>>
>> Hi
>>
>> I am working on a Coupon form in which I have some optional fields. 
>>
>> *Introduction:*
>>
>> All the form field values are received as JSON and mapped into a Golang 
>> structure. In the structure, I have added an "omitempty" flag with every 
>> field. So only those form values are mapped which have some appropriate 
>> value, rest of the values like 0, " ", false are ignored by the structure.
>>
>> Here is the Golang structure
>>
>> type Coupon struct {
>> Id   int`json:"id,omitempty" bson:"_id,omitempty"`
>> Name string `json:"name,omitempty" bson:"name,omitempty"`
>> Code string `json:"code,omitempty" bson:"code,omitempty"`
>> Description  string `json:"description,omitempty" 
>> bson:"description,omitempty"`
>> Status   bool   `json:"status" bson:"status"`
>> MaxUsageLimitint`json:"max_usage_limit,omitempty" 
>> bson:"max_usage_limit,omitempty"`
>> SingleUsePerUser bool   `json:"single_use_per_user,omitempty" 
>> bson:"single_use_per_user,omitempty"`}
>>
>> *Problem:*
>>
>>1. 
>>
>>When I save this form for the very first time, the form values that 
>>are appropriate are saved into the Mongodb.
>>2. 
>>
>>Now I want to update that form and suppose there is a check box, 
>>which was checked at the time of saving data. While updating form, the 
>>checkbox is unchecked and form is submitted to save. Now as I have 
>> applied 
>>"omitempty" flag in the structure, so its not mapping the empty value to 
>>the checkbox field. Since the value is not mapped into the structure, its 
>>not getting saved into the Database. 
>>3. 
>>
>>When a user edits the form for the second time, it sees the same 
>>check box as checked. (But practically, the value should be updated to 
>> the 
>>DB and the check box should be displayed as unchecked.)
>>4. 
>>
>>I am using the same form data (in JSON format) in a REST API. In API, 
>>while updating form data, if I mention only those values which are 
>> required 
>>and don't pass the values which I don't want to update, then MongoDB is 
>>overriding the whole document with the provided required values(Even 
>> those 
>>values are also being overridden which I don't want to update as well as 
>>don't pass in the API).
>>
>> *Requirement:*
>>
>> In future, I want to expose the REST API, So I don't want this thing to 
>> be happened there. That is why I don't want to remove "omitempty" flag from 
>> the structure fields. 
>>
>> Is there any way to save the empty form values or API data fields to the 
>> DB while using omitempty flag in the structure?
>>
>> Thanks!
>>
>

-- 
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.


[go-nuts] Update Mongodb fields with omitempty flag in Golang structure

2017-11-07 Thread Amandeep Kaur


Hi

I am working on a Coupon form in which I have some optional fields. 

*Introduction:*

All the form field values are received as JSON and mapped into a Golang 
structure. In the structure, I have added an "omitempty" flag with every 
field. So only those form values are mapped which have some appropriate 
value, rest of the values like 0, " ", false are ignored by the structure.

Here is the Golang structure

type Coupon struct {
Id   int`json:"id,omitempty" bson:"_id,omitempty"`
Name string `json:"name,omitempty" bson:"name,omitempty"`
Code string `json:"code,omitempty" bson:"code,omitempty"`
Description  string `json:"description,omitempty" 
bson:"description,omitempty"`
Status   bool   `json:"status" bson:"status"`
MaxUsageLimitint`json:"max_usage_limit,omitempty" 
bson:"max_usage_limit,omitempty"`
SingleUsePerUser bool   `json:"single_use_per_user,omitempty" 
bson:"single_use_per_user,omitempty"`}

*Problem:*

   1. 
   
   When I save this form for the very first time, the form values that are 
   appropriate are saved into the Mongodb.
   2. 
   
   Now I want to update that form and suppose there is a check box, which 
   was checked at the time of saving data. While updating form, the checkbox 
   is unchecked and form is submitted to save. Now as I have applied 
   "omitempty" flag in the structure, so its not mapping the empty value to 
   the checkbox field. Since the value is not mapped into the structure, its 
   not getting saved into the Database. 
   3. 
   
   When a user edits the form for the second time, it sees the same check 
   box as checked. (But practically, the value should be updated to the DB and 
   the check box should be displayed as unchecked.)
   4. 
   
   I am using the same form data (in JSON format) in a REST API. In API, 
   while updating form data, if I mention only those values which are required 
   and don't pass the values which I don't want to update, then MongoDB is 
   overriding the whole document with the provided required values(Even those 
   values are also being overridden which I don't want to update as well as 
   don't pass in the API).
   
*Requirement:*

In future, I want to expose the REST API, So I don't want this thing to be 
happened there. That is why I don't want to remove "omitempty" flag from 
the structure fields. 

Is there any way to save the empty form values or API data fields to the DB 
while using omitempty flag in the structure?

Thanks!

-- 
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.