bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Hurd port for gcc go PATCH 1-4(23)


From: Svante Signell
Subject: Re: Hurd port for gcc go PATCH 1-4(23)
Date: Wed, 07 Dec 2016 14:52:35 +0100

On Sun, 2016-11-27 at 18:02 +0100, Samuel Thibault wrote:
> Hello,
> 
> Svante Signell, on Sun 27 Nov 2016 17:33:52 +0100, wrote:
> > > > 
> > > And
> > > src_libgo_go_syscall_syscall_gnu_test.go: New file:
> > >   Define Type and Whence as 32bit in syscall.Flock_t
> > > 
> > > Again, you'll probably have to discuss with upstream to see how they
> > > prefer to make it configurable rather than forking the whole file.
> > > 

I found the answer, see below!

> > I tried to patch the syscall_unix_test.go file, but did not succeed. 
> > Definitely if runtime.GOOS == "GNU" ... else ... or switch runtime.GOOS
> > ... does not work. The compiler sees all code and complains, also the
> > else part of the code :( Therefore I created a new file.
> 
> Then ask upstream how they think it can and should be done.
> 

Since go does not have a preprocessor allowing conditional code paths this is
how it should be done (and as I did):
http://blog.ralch.com/tutorial/golang-conditional-compilation/

Verdict
=======
We should aim to develop and build our Go applications by following Go idioms.
If the source file targets a specific platform, we should choose file suffix
approach. Otherwise, if the source file is applicable for multiple platforms and
we want to exclude a specific feature or platform, we should use build
constraints instead.

Build constraints
=================
A build constraints (known as build tags) is an optional top line comment that
starts with

// +build

package api

File suffixes
=============
The second option for conditional compilation is the name of the
source file itself. This approach is simpler than build tags, and allows
the Go build system to exclude files without having to process the file.

We should add one of the following suffixes to desired files:

*_GOOS // operation system
*_GOARCH // platform architecture
*_GOOS_GOARCH // both combined




reply via email to

[Prev in Thread] Current Thread [Next in Thread]