Re: [go-nuts] Go ARM

2023-11-15 Thread Stephen Illingworth
On Wednesday, 15 November 2023 at 21:25:37 UTC Def Ceb wrote:

I downloaded and ran `go env` with both the 32-bit and 64-bit Go 
toolchains from go.dev, and the GOGCCFLAGS results were: 

Since you're on a newer Raspberry Pi with a 64-bit ARM environment, you 
should download the 64-bit Go toolchain, not the 32-bit one. 


That's it! Thank you. Not sure why I didn't spot the ARM64 build on the 
download page. 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f921505c-8ddb-40ff-b441-5d785bd3b939n%40googlegroups.com.


Re: [go-nuts] Go ARM

2023-11-15 Thread Def Ceb
I downloaded and ran `go env` with both the 32-bit and 64-bit Go 
toolchains from go.dev, and the GOGCCFLAGS results were:


64-bit: GOGCCFLAGS='-fPIC -pthread -Wl,--no-gc-sections 
-fmessage-length=0 
-ffile-prefix-map=/tmp/go-build2828356582=/tmp/go-build 
-gno-record-gcc-switches'


32-bit: GOGCCFLAGS='-fPIC -marm -pthread -Wl,--no-gc-sections 
-fmessage-length=0 
-ffile-prefix-map=/tmp/go-build3860201885=/tmp/go-build 
-gno-record-gcc-switches'


Since you're on a newer Raspberry Pi with a 64-bit ARM environment, you 
should download the 64-bit Go toolchain, not the 32-bit one.


Stephen Illingworth:

Hello,

I'm trying to build a project on the Raspberry Pi, natively.

Using "go env" I can see that Go has the following value for GOGCCFLAGS

GOGCCFLAGS='-fPIC -marm -Wl,--no-gc-sections -fmessage-length=0 
-ffile-prefix-map=/tmp/go-build745518569=/tmp/go-build 
-gno-record-gcc-switches'


However, the native compiler (gcc 12.2) does not have the -marm flag. 
The compilation of the project fails.


I know you can't edit the GOGCCFLAGS environment variable directly but 
it's not clear to me how to remove this unneeded flag.


I've tried the CGO_CFLAGS_DISALLOW environment variable but that doesn't 
seem work. But maybe I'm misusing it.


This is a brand new installation of Raspbian. The only other software 
I've installed is Go for Arm from the official Go distribution site.


Help
Stephen

--
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 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/82a69c96-5cbd-4aa2-a911-8141071b2610n%40googlegroups.com .


--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/178af2a6-a611-40c8-9e1f-ac0881d14af6%40gmail.com.


Re: [go-nuts] Go ARM

2023-11-15 Thread Jan Mercl
On Wed, Nov 15, 2023 at 9:59 PM Stephen Illingworth
 wrote:
>
> That works better although not perfectly for my purposes. More work required 
> from me.
>
> I'm curious though, about the -marm flag. How can I remove it from the 
> GOGCCFLAGS variable? Or are we saying we can't use the aarch64 compiler in 
> conjunction with cgo?

Please share the output of '$ go version' and the output of '$ gcc
-dumpmachine'.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAA40n-XALZibTeEh9erHvN74Wa_rwF%3Dqwb9Jgz15HadK_8hsxQ%40mail.gmail.com.


Re: [go-nuts] Go ARM

2023-11-15 Thread Stephen Illingworth
That works better although not perfectly for my purposes. More work 
required from me.

I'm curious though, about the -marm flag. How can I remove it from the 
GOGCCFLAGS variable? Or are we saying we can't use the aarch64 compiler in 
conjunction with cgo?

Thanks for the help

On Wednesday, 15 November 2023 at 20:05:59 UTC Jan Mercl wrote:

> On Wed, Nov 15, 2023 at 8:30 PM Stephen Illingworth <
> stephen.i...@gmail.com> wrote:
> > I'm trying to build a project on the Raspberry Pi, natively.
> >
> > Using "go env" I can see that Go has the following value for GOGCCFLAGS
> >
> > GOGCCFLAGS='-fPIC -marm -Wl,--no-gc-sections -fmessage-length=0 
> -ffile-prefix-map=/tmp/go-build745518569=/tmp/go-build 
> -gno-record-gcc-switches'
> >
> > However, the native compiler (gcc 12.2) does not have the -marm flag. 
> The compilation of the project fails.
>
> From the above I guess you might be running gcc for aarch64 as the arm 
> version accepts the -marm flag here:
>
> jnml@pi32:~/tmp/gcc$ go version
> go version go1.21.4 linux/arm
> jnml@pi32:~/tmp/gcc$ cat main.c 
> #include 
>
> int main() {
> printf("Hello, world!\n");
> }
> jnml@pi32:~/tmp/gcc$ rm -f a.out ; gcc -marm main.c && ./a.out && echo ok
> Hello, world!
> ok
> jnml@pi32:~/tmp/gcc$ gcc --version
> gcc (Raspbian 10.2.1-6+rpi1) 10.2.1 20210110
> Copyright (C) 2020 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.
>
> jnml@pi32:~/tmp/gcc$ 
>
> I tried the solution from 
> https://jensd.be/1126/linux/cross-compiling-for-arm-or-aarch64-on-debian-or-ubuntu
>  
> and it seems to work fine:
>
> jnml@pi64:~/tmp/gcc$ jnml@pi64:~/tmp/gcc$ go version
> go version go1.21.4 linux/arm64
> jnml@pi64:~/tmp/gcc$ cat main.c
> #include 
>
> int main() {
> printf("Hello, world!\n");
> }
> jnml@pi64:~/tmp/gcc$ rm -f a.out ; gcc main.c && ./a.out && echo ok
> Hello, world!
> ok
> jnml@pi64:~/tmp/gcc$ rm -f a.out ; gcc -marm main.c && ./a.out && echo ok
> gcc: error: unrecognized command-line option ‘-marm’
> jnml@pi64:~/tmp/gcc$ sudo apt install gcc-arm-linux-gnueabi 
> binutils-arm-linux-gnueabi
> ...
> jnml@pi64:~/tmp/gcc$ rm -f a.out ; arm-linux-gnueabi-gcc -marm main.c && 
> file a.out
> a.out: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically 
> linked, interpreter /lib/ld-linux.so.3, 
> BuildID[sha1]=2191a16290d46b039bfae26fd5918106dff99749, for GNU/Linux 
> 3.2.0, not stripped
> jnml@pi64:~/tmp/gcc$
>
> HTH
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/af718786-7479-4a98-bfb2-7feee41017can%40googlegroups.com.


Re: [go-nuts] Go ARM

2023-11-15 Thread Jan Mercl
On Wed, Nov 15, 2023 at 8:30 PM Stephen Illingworth <
stephen.illingwo...@gmail.com> wrote:
> I'm trying to build a project on the Raspberry Pi, natively.
>
> Using "go env" I can see that Go has the following value for GOGCCFLAGS
>
> GOGCCFLAGS='-fPIC -marm -Wl,--no-gc-sections -fmessage-length=0
-ffile-prefix-map=/tmp/go-build745518569=/tmp/go-build
-gno-record-gcc-switches'
>
> However, the native compiler (gcc 12.2) does not have the -marm flag. The
compilation of the project fails.

>From the above I guess you might be running gcc for aarch64 as the arm
version accepts the -marm flag here:

jnml@pi32:~/tmp/gcc$ go version
go version go1.21.4 linux/arm
jnml@pi32:~/tmp/gcc$ cat main.c
#include 

int main() {
printf("Hello, world!\n");
}
jnml@pi32:~/tmp/gcc$ rm -f a.out ; gcc -marm main.c && ./a.out && echo ok
Hello, world!
ok
jnml@pi32:~/tmp/gcc$ gcc --version
gcc (Raspbian 10.2.1-6+rpi1) 10.2.1 20210110
Copyright (C) 2020 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.

jnml@pi32:~/tmp/gcc$

I tried the solution from
https://jensd.be/1126/linux/cross-compiling-for-arm-or-aarch64-on-debian-or-ubuntu
and it seems to work fine:

jnml@pi64:~/tmp/gcc$ jnml@pi64:~/tmp/gcc$ go version
go version go1.21.4 linux/arm64
jnml@pi64:~/tmp/gcc$ cat main.c
#include 

int main() {
printf("Hello, world!\n");
}
jnml@pi64:~/tmp/gcc$ rm -f a.out ; gcc main.c && ./a.out && echo ok
Hello, world!
ok
jnml@pi64:~/tmp/gcc$ rm -f a.out ; gcc -marm main.c && ./a.out && echo ok
gcc: error: unrecognized command-line option ‘-marm’
jnml@pi64:~/tmp/gcc$ sudo apt install gcc-arm-linux-gnueabi
binutils-arm-linux-gnueabi
...
jnml@pi64:~/tmp/gcc$ rm -f a.out ; arm-linux-gnueabi-gcc -marm main.c &&
file a.out
a.out: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically
linked, interpreter /lib/ld-linux.so.3,
BuildID[sha1]=2191a16290d46b039bfae26fd5918106dff99749, for GNU/Linux
3.2.0, not stripped
jnml@pi64:~/tmp/gcc$

HTH

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAA40n-UeuRqwty-w8Z%3D1%2B3rEt1xJqKYc%3DELCWK4DjUOzjuCRvw%40mail.gmail.com.


[go-nuts] Go ARM

2023-11-15 Thread Stephen Illingworth
Hello,

I'm trying to build a project on the Raspberry Pi, natively.

Using "go env" I can see that Go has the following value for GOGCCFLAGS

GOGCCFLAGS='-fPIC -marm -Wl,--no-gc-sections -fmessage-length=0 
-ffile-prefix-map=/tmp/go-build745518569=/tmp/go-build 
-gno-record-gcc-switches'

However, the native compiler (gcc 12.2) does not have the -marm flag. The 
compilation of the project fails.

I know you can't edit the GOGCCFLAGS environment variable directly but it's 
not clear to me how to remove this unneeded flag.

I've tried the CGO_CFLAGS_DISALLOW environment variable but that doesn't 
seem work. But maybe I'm misusing it.

This is a brand new installation of Raspbian. The only other software I've 
installed is Go for Arm from the official Go distribution site.

Help
Stephen

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/82a69c96-5cbd-4aa2-a911-8141071b2610n%40googlegroups.com.