├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── build.sh ├── go1.12.4-fix.diff ├── go1.16.6-fix.diff └── go1.17.13-fix.diff /.gitignore: -------------------------------------------------------------------------------- 1 | *.gz 2 | *.xz 3 | go-src -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM darrenhoo/centos5-go-bootstrap:1.17.13 2 | 3 | ADD go-src /usr/local/go 4 | RUN cd /usr/local/go/src/; ./make.bash 5 | RUN cd /usr/local/; rm -rf go/pkg/obj; tar cf - go | xz -z - > /go.tar.xz 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Build Go on CentOS5 2 | 3 | *WARNING: Go has never been supported on CentOS5, use on your own risk.* 4 | 5 | ## Building using docker 6 | 7 | Ensure that `wget patch docker` are installed on host then run `build.sh` 8 | 9 | go${VERSION}-CentOS5.linux-amd64.tar.xz will be copied on current diretory if successfully built. 10 | 11 | Prebuilt binary can be downloaded from [releases](https://github.com/darren/golang-on-centos5/releases) 12 | 13 | ## References 14 | 15 | 1. [How to install Go 1.1 on CentOS 5.9 by Dave Cheney](https://dave.cheney.net/2013/06/18/how-to-install-go-1-1-on-centos-5) 16 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | VERSION=1.17.13 4 | ARTIFACT=go${VERSION}-CentOS5.linux-amd64.tar.xz 5 | IMAGE_TAG=centos5-go${VERSION} 6 | SOURCE_DIR=go-src 7 | SOURCE_TGZ=go${VERSION}.src.tar.gz 8 | 9 | function FAIL() { 10 | echo "$1" 11 | exit 1 12 | } 13 | 14 | if [[ ! -r $SOURCE_TGZ ]]; then 15 | wget https://dl.google.com/go/$SOURCE_TGZ 16 | fi 17 | 18 | if [[ ! -r $SOURCE_TGZ ]]; then 19 | FAIL "$SOURCE_TGZ not found" 20 | fi 21 | 22 | if [[ -r $SOURCE_DIR ]]; then 23 | echo "Clean files" 24 | rm -rf $SOURCE_DIR 25 | fi 26 | 27 | tar zxf $SOURCE_TGZ 28 | mv go $SOURCE_DIR 29 | patch -p1 -d $SOURCE_DIR < go${VERSION}-fix.diff 30 | 31 | if [[ -r $SOURCE_DIR ]]; then 32 | docker build . -t $IMAGE_TAG || FAIL "build failed" 33 | docker run -d -t $IMAGE_TAG /bin/bash 34 | CONTAINER_ID=$(docker ps -alq) 35 | docker cp $CONTAINER_ID:/go.tar.xz $ARTIFACT 36 | docker stop $CONTAINER_ID 37 | else 38 | FAIL "source not found: go${VERSION}" 39 | fi 40 | 41 | if [[ -r $ARTIFACT ]]; then 42 | echo "Build output: $ARTIFACT" 43 | else 44 | FAIL "Build failed" 45 | fi 46 | -------------------------------------------------------------------------------- /go1.12.4-fix.diff: -------------------------------------------------------------------------------- 1 | diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go 2 | index 0cf8b17..00e2f97 100644 3 | --- a/src/cmd/cgo/out.go 4 | +++ b/src/cmd/cgo/out.go 5 | @@ -776,13 +776,6 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) { 6 | fmt.Fprintf(fgcc, "#include \n") 7 | fmt.Fprintf(fgcc, "#include \"_cgo_export.h\"\n\n") 8 | 9 | - // We use packed structs, but they are always aligned. 10 | - // The pragmas and address-of-packed-member are not recognized as warning groups in clang 3.4.1, so ignore unknown pragmas first. 11 | - // remove as part of #27619 (all: drop support for FreeBSD 10). 12 | - fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n") 13 | - fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Wpragmas\"\n") 14 | - fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Waddress-of-packed-member\"\n") 15 | - 16 | fmt.Fprintf(fgcc, "extern void crosscall2(void (*fn)(void *, int, __SIZE_TYPE__), void *, int, __SIZE_TYPE__);\n") 17 | fmt.Fprintf(fgcc, "extern __SIZE_TYPE__ _cgo_wait_runtime_init_done();\n") 18 | fmt.Fprintf(fgcc, "extern void _cgo_release_context(__SIZE_TYPE__);\n\n") 19 | @@ -1480,14 +1473,6 @@ __cgo_size_assert(double, 8) 20 | 21 | extern char* _cgo_topofstack(void); 22 | 23 | -/* We use packed structs, but they are always aligned. */ 24 | -/* The pragmas and address-of-packed-member are not recognized as warning groups in clang 3.4.1, so ignore unknown pragmas first. */ 25 | -/* remove as part of #27619 (all: drop support for FreeBSD 10). */ 26 | - 27 | -#pragma GCC diagnostic ignored "-Wunknown-pragmas" 28 | -#pragma GCC diagnostic ignored "-Wpragmas" 29 | -#pragma GCC diagnostic ignored "-Waddress-of-packed-member" 30 | - 31 | #include 32 | #include 33 | ` 34 | diff --git a/src/runtime/sys_linux_amd64.s b/src/runtime/sys_linux_amd64.s 35 | index b709f77..f6ae4b0 100644 36 | --- a/src/runtime/sys_linux_amd64.s 37 | +++ b/src/runtime/sys_linux_amd64.s 38 | @@ -40,6 +40,7 @@ 39 | #define SYS_sched_getaffinity 204 40 | #define SYS_epoll_create 213 41 | #define SYS_exit_group 231 42 | +#define SYS_epoll_wait 232 43 | #define SYS_epoll_ctl 233 44 | #define SYS_tgkill 234 45 | #define SYS_openat 257 46 | @@ -669,8 +670,7 @@ TEXT runtime·epollwait(SB),NOSPLIT,$0 47 | MOVQ ev+8(FP), SI 48 | MOVL nev+16(FP), DX 49 | MOVL timeout+20(FP), R10 50 | - MOVQ $0, R8 51 | - MOVL $SYS_epoll_pwait, AX 52 | + MOVL $SYS_epoll_wait, AX 53 | SYSCALL 54 | MOVL AX, ret+24(FP) 55 | RET 56 | -------------------------------------------------------------------------------- /go1.16.6-fix.diff: -------------------------------------------------------------------------------- 1 | diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go 2 | index 1fddbb6..410c182 100644 3 | --- a/src/cmd/cgo/out.go 4 | +++ b/src/cmd/cgo/out.go 5 | @@ -814,9 +814,9 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) { 6 | // We use packed structs, but they are always aligned. 7 | // The pragmas and address-of-packed-member are only recognized as 8 | // warning groups in clang 4.0+, so ignore unknown pragmas first. 9 | - fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n") 10 | - fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Wpragmas\"\n") 11 | - fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Waddress-of-packed-member\"\n") 12 | + // fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n") 13 | + // fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Wpragmas\"\n") 14 | + // fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Waddress-of-packed-member\"\n") 15 | 16 | fmt.Fprintf(fgcc, "extern void crosscall2(void (*fn)(void *, int, __SIZE_TYPE__), void *, int, __SIZE_TYPE__);\n") 17 | fmt.Fprintf(fgcc, "extern __SIZE_TYPE__ _cgo_wait_runtime_init_done(void);\n") 18 | @@ -1519,10 +1519,10 @@ extern char* _cgo_topofstack(void); 19 | We use packed structs, but they are always aligned. 20 | The pragmas and address-of-packed-member are only recognized as warning 21 | groups in clang 4.0+, so ignore unknown pragmas first. 22 | -*/ 23 | #pragma GCC diagnostic ignored "-Wunknown-pragmas" 24 | #pragma GCC diagnostic ignored "-Wpragmas" 25 | #pragma GCC diagnostic ignored "-Waddress-of-packed-member" 26 | +*/ 27 | 28 | #include 29 | #include 30 | diff --git a/src/runtime/sys_linux_amd64.s b/src/runtime/sys_linux_amd64.s 31 | index 5c300f5..909f123 100644 32 | --- a/src/runtime/sys_linux_amd64.s 33 | +++ b/src/runtime/sys_linux_amd64.s 34 | @@ -40,6 +40,7 @@ 35 | #define SYS_sched_getaffinity 204 36 | #define SYS_epoll_create 213 37 | #define SYS_exit_group 231 38 | +#define SYS_epoll_wait 232 39 | #define SYS_epoll_ctl 233 40 | #define SYS_tgkill 234 41 | #define SYS_openat 257 42 | @@ -667,8 +668,7 @@ TEXT runtime·epollwait(SB),NOSPLIT,$0 43 | MOVQ ev+8(FP), SI 44 | MOVL nev+16(FP), DX 45 | MOVL timeout+20(FP), R10 46 | - MOVQ $0, R8 47 | - MOVL $SYS_epoll_pwait, AX 48 | + MOVL $SYS_epoll_wait, AX 49 | SYSCALL 50 | MOVL AX, ret+24(FP) 51 | RET 52 | -------------------------------------------------------------------------------- /go1.17.13-fix.diff: -------------------------------------------------------------------------------- 1 | diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go 2 | index a73e998877..c3d61f4c5e 100644 3 | --- a/src/cmd/cgo/gcc.go 4 | +++ b/src/cmd/cgo/gcc.go 5 | @@ -1639,7 +1639,7 @@ func (p *Package) gccCmd() []string { 6 | c = append(c, "-mcmodel=large") 7 | } 8 | // disable LTO so we get an object whose symbols we can read 9 | - c = append(c, "-fno-lto") 10 | + // c = append(c, "-fno-lto") 11 | c = append(c, "-") //read input from standard input 12 | return c 13 | } 14 | diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go 15 | index 94152f4278..fa965d8362 100644 16 | --- a/src/cmd/cgo/out.go 17 | +++ b/src/cmd/cgo/out.go 18 | @@ -881,9 +881,9 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) { 19 | // We use packed structs, but they are always aligned. 20 | // The pragmas and address-of-packed-member are only recognized as 21 | // warning groups in clang 4.0+, so ignore unknown pragmas first. 22 | - fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n") 23 | - fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Wpragmas\"\n") 24 | - fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Waddress-of-packed-member\"\n") 25 | + // fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n") 26 | + // fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Wpragmas\"\n") 27 | + // fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Waddress-of-packed-member\"\n") 28 | 29 | fmt.Fprintf(fgcc, "extern void crosscall2(void (*fn)(void *), void *, int, __SIZE_TYPE__);\n") 30 | fmt.Fprintf(fgcc, "extern __SIZE_TYPE__ _cgo_wait_runtime_init_done(void);\n") 31 | @@ -1477,10 +1477,10 @@ extern char* _cgo_topofstack(void); 32 | We use packed structs, but they are always aligned. 33 | The pragmas and address-of-packed-member are only recognized as warning 34 | groups in clang 4.0+, so ignore unknown pragmas first. 35 | -*/ 36 | #pragma GCC diagnostic ignored "-Wunknown-pragmas" 37 | #pragma GCC diagnostic ignored "-Wpragmas" 38 | #pragma GCC diagnostic ignored "-Waddress-of-packed-member" 39 | +*/ 40 | 41 | #include 42 | #include 43 | diff --git a/src/runtime/sys_linux_amd64.s b/src/runtime/sys_linux_amd64.s 44 | index 33cc670b64..1b6abce31b 100644 45 | --- a/src/runtime/sys_linux_amd64.s 46 | +++ b/src/runtime/sys_linux_amd64.s 47 | @@ -43,6 +43,7 @@ 48 | #define SYS_epoll_create 213 49 | #define SYS_clock_gettime 228 50 | #define SYS_exit_group 231 51 | +#define SYS_epoll_wait 232 52 | #define SYS_epoll_ctl 233 53 | #define SYS_tgkill 234 54 | #define SYS_openat 257 55 | @@ -660,8 +661,7 @@ TEXT runtime·epollwait(SB),NOSPLIT,$0 56 | MOVQ ev+8(FP), SI 57 | MOVL nev+16(FP), DX 58 | MOVL timeout+20(FP), R10 59 | - MOVQ $0, R8 60 | - MOVL $SYS_epoll_pwait, AX 61 | + MOVL $SYS_epoll_wait, AX 62 | SYSCALL 63 | MOVL AX, ret+24(FP) 64 | RET 65 | --------------------------------------------------------------------------------