1 # NOTE: build needs >128 processes limit
3 # - allow disabling tests (currently bcond exists just for showing which are test deps)
4 # - add verbose build output (currently dummy bcond)
5 # - setup GOMAXPROCS=2 from _smp_mflags
6 # - fix CC containing spaces (ccache)
7 # - check if hg use at build time can be dropped
8 # - build all target archs, subpackage them: http://golang.org/doc/install/source#environment
9 # or choose only useful crosscompilers?
10 # - subpackage -src files?
13 %bcond_without verbose # verbose build (V=1)
14 %bcond_without tests # build without tests [nop actually]
15 %bcond_without shared # Build golang shared objects for stdlib
16 %bcond_without ext_linker # Build golang using external/internal (close to cgo disabled) linking
17 %bcond_without cgo # cgo (importing C libraries) support
18 %bcond_with bootstrap # bootstrap build
20 %ifnarch %{ix86} %{x8664} %{arm} aarch64 mips64 mips64le ppc64le
22 %undefine with_ext_linker
26 Summary: Go compiler and tools
27 Summary(pl.UTF-8): Kompilator języka Go i narzędzia
31 # source tree includes several copies of Mark.Twain-Tom.Sawyer.txt under Public Domain
32 License: BSD and Public Domain
33 Group: Development/Languages
34 # Source0Download: https://golang.org/dl/
35 Source0: https://storage.googleapis.com/golang/go%{version}.src.tar.gz
36 # Source0-md5: c22dfda9edbbfcc23e598121db8533c8
37 Patch0: ca-certs.patch
38 Patch1: 0001-Don-t-use-the-bundled-tzdata-at-runtime-except-for-t.patch
39 URL: https://golang.org/
41 BuildRequires: rpm-build >= 4.6
42 BuildRequires: rpm-pythonprov
43 # The compiler is written in Go. Needs go(1.4+) compiler for build.
45 BuildRequires: gcc-go >= 6:5
47 BuildRequires: golang >= 1.4
50 BuildRequires: glibc-static
51 BuildRequires: hostname
52 BuildRequires: pcre-devel
53 BuildRequires: rpmbuild(macros) >= 2.007
56 Requires: ca-certificates
58 ExclusiveArch: %{ix86} %{x8664} %{armv5} %{armv6} %{armv7} aarch64 mips mipsel mips64 mips64el ppc64 ppc64le riscv64 s390x
59 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
61 %define no_install_post_strip 1
62 %define no_install_post_chrpath 1
63 %define _enable_debug_packages 0
64 %define _noautoreqfiles %{_libdir}/%{name}/src
66 %define goroot %{_libdir}/%{name}
93 %define GOARCH mips64le
95 %ifarch mips mips64 ppc64 ppc64le riscv64 s390x
96 %define GOARCH %{_arch}
100 Go is an open source programming environment that makes it easy to
101 build simple, reliable, and efficient software.
103 %description -l pl.UTF-8
104 Go to mające otwarte źródła środowisko do programowania, pozwalające
105 na łatwe tworzenie prostych, pewnych i wydajnych programów.
108 Summary: Golang shared object libraries
109 Summary(pl.UTF-8): Biblioteki obiektów współdzielonych dla języka Go
111 Requires: %{name} = %{version}-%{release}
114 Golang shared object libraries.
116 %description shared -l pl.UTF-8
117 Biblioteki obiektów współdzielonych dla języka Go.
120 Summary: Documentation for Go language
121 Summary(fr.UTF-8): Documentation pour Go
122 Summary(it.UTF-8): Documentazione di Go
123 Summary(pl.UTF-8): Dokumentacja do języka Go
128 Documentation for Go language.
130 %description doc -l fr.UTF-8
131 Documentation pour Go.
133 %description doc -l it.UTF-8
134 Documentazione di Go.
136 %description doc -l pl.UTF-8
137 Dokumentacja do języka Go.
145 # clean patch backups
146 find . -name '*.orig' | xargs -r %{__rm}
149 # bootstrap compiler GOROOT
150 %if %{with bootstrap}
151 export GOROOT_BOOTSTRAP=%{_prefix}
153 export GOROOT_BOOTSTRAP=%{goroot}
155 export GOROOT_FINAL=%{goroot}
157 export GOHOSTOS=linux
158 export GOHOSTARCH=%{GOARCH}
161 export GOARCH=%{GOARCH}
162 %{?GOARM:export GOARM=%{GOARM}}
164 %ifarch %{x86_with_sse2}
167 export GO386=softfloat
170 %if %{without ext_linker}
171 export GO_LDFLAGS="-linkmode internal"
179 # use our gcc options for this build, but store gcc as default for compiler
180 export CFLAGS="%{rpmcflags}"
181 export LDFLAGS="%{rpmldflags}"
184 export CC="${CC#ccache }"
185 export CC_FOR_TARGET="$CC"
188 grep -rl '#!.*env bash' . | xargs %{__sed} -i -e '1{
189 s,^#!.*bin/env bash,#!%{__bash},
193 # optflags for go tools build
194 nflags="\"$(echo '%{rpmcflags}' | sed -e 's/^[ ]*//;s/[ ]*$//;s/[ ]\+/ /g' -e 's/ /\",\"/g')\""
195 %{__sed} -i -e "s/\"-O2\"/$nflags/" src/cmd/dist/build.c
196 # NOTE: optflags used in gcc calls from go compiler are in src/cmd/go/build.go
202 ./make.bash --no-clean
205 # build shared std lib
207 GOROOT=$(pwd) PATH=$(pwd)/bin:$PATH go install -buildmode=shared std
211 rm -rf $RPM_BUILD_ROOT
212 GOROOT=$RPM_BUILD_ROOT%{goroot}
214 install -d $GOROOT/{misc,lib,src}
215 install -d $RPM_BUILD_ROOT%{_bindir}
217 cp -a pkg lib bin src VERSION $GOROOT
218 cp -a misc/cgo $GOROOT/misc
220 # kill Win32 and Plan9 scripts
221 find $GOROOT -name '*.bat' -o -name '*.rc' | xargs %{__rm}
223 # https://github.com/golang/go/issues/4749
224 find $GOROOT/src | xargs touch -r $GOROOT/VERSION
225 # and level out all the built archives
227 find $GOROOT/pkg | xargs touch -r $GOROOT/pkg
229 ln -sf %{_libdir}/%{name}/bin/go $RPM_BUILD_ROOT%{_bindir}/go
230 ln -sf %{_libdir}/%{name}/bin/gofmt $RPM_BUILD_ROOT%{_bindir}/gofmt
231 ln -sf %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/cgo $RPM_BUILD_ROOT%{_bindir}/cgo
233 # FIXME: do we need whole sources, including build scripts?
234 # for now, remove only non-Linux stuff
236 $RPM_BUILD_ROOT%{_libdir}/%{name}/src/syscall/{mksyscall,mksysctl_openbsd,mksysnum_{dragonfly,freebsd,netbsd,openbsd}}.pl
238 %{__rm} -r $RPM_BUILD_ROOT%{_libdir}/%{name}/src/internal/trace \
239 $RPM_BUILD_ROOT%{_libdir}/%{name}/misc/cgo/{errors,fortran,test*}
240 find $RPM_BUILD_ROOT%{_libdir}/%{name} -name testdata -prune | xargs %{__rm} -r
242 # unenvize remaining scripts
243 %{__sed} -i -e '1s,/usr/bin/env bash,/bin/bash,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/*.bash
244 %{__sed} -i -e '1s,/usr/bin/env bash,/bin/bash,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/syscall/*.sh
245 %{__sed} -i -e '1s,/usr/bin/env bash,/bin/bash,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/cmd/vendor/golang.org/x/sys/unix/*.sh
246 %{__sed} -i -e '1s,/usr/bin/env bash,/bin/bash,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/cmd/go/*.sh
247 %{__sed} -i -e '1s,/usr/bin/env perl,/usr/bin/perl,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/syscall/*.pl
250 rm -rf $RPM_BUILD_ROOT
253 %defattr(644,root,root,755)
254 %doc AUTHORS CONTRIBUTORS LICENSE
255 %attr(755,root,root) %{_bindir}/cgo
256 %attr(755,root,root) %{_bindir}/go
257 %attr(755,root,root) %{_bindir}/gofmt
258 %dir %{_libdir}/%{name}
259 %{_libdir}/%{name}/VERSION
260 %dir %{_libdir}/%{name}/bin
261 %attr(755,root,root) %{_libdir}/%{name}/bin/go
262 %attr(755,root,root) %{_libdir}/%{name}/bin/gofmt
264 %{_libdir}/%{name}/lib
265 %{_libdir}/%{name}/misc
266 %{_libdir}/%{name}/src
267 %dir %{_libdir}/%{name}/pkg
268 %{_libdir}/%{name}/pkg/linux_%{GOARCH}
269 %{_libdir}/%{name}/pkg/obj
270 %dir %{_libdir}/%{name}/pkg/tool
271 %dir %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}
272 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/addr2line
273 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/api
274 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/asm
275 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/buildid
276 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/cgo
277 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/compile
278 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/cover
279 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/dist
280 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/doc
281 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/fix
282 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/link
283 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/nm
284 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/objdump
285 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/pack
286 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/pprof
287 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/test2json
288 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/trace
289 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/vet
291 %{_libdir}/%{name}/pkg/include
295 %defattr(644,root,root,755)
296 %{_libdir}/%{name}/pkg/linux_%{GOARCH}_dynlink
300 %defattr(644,root,root,755)