dsouza
October 21, 2024, 1:40pm
1
I use to do my own OpenWrt builds. I can build just fine in Ubuntu on WSL2.
However I am trying to build on Armbian/Orange Pi5 as an experiment (targeting ARM64, so no cross-compilation is needed) and I am getting the following error during GoLang build:
make[3]: Entering directory '/home/dsouza/openwrt/r4s-router-23.05.5/feeds/packages/lang/golang/golang'
Makefile:402: *** go-bootstrap cannot be installed on linux/arm64. Stop.
I know that building on ARM64 platform is not officially supported , but just asking here if by chance anyone has successfully built OpenWrt in a ARM64 build environment and if there is any workaround for this issue.
brada4
October 21, 2024, 1:44pm
2
You can install armbian provided go compiler to serve as bootstrap.
dsouza
October 21, 2024, 2:40pm
3
That's what I did, but it is not working.
I've found the issue below, reading now (I believe I need to point the make file manually to the external golang compiler):
opened 04:30AM - 01 Apr 20 UTC
closed 07:57PM - 28 May 20 UTC
Maintainer: @jefferyto
Environment: Host is RK3328(aarch64) box, SDK is self bu… ild from OpenWrt v19.07.2 source
Description:
Before building any app written in go, a bootstrap blob is need to generate a host go compiler.
Currently this is `go1.4-bootstrap-20171003.tar.gz`.
As we all known, arm64 is not support in go 1.4.
But I'm perfer to build ipks in my small arm box, and I managed to work it out with a few problem to resolve.
Here is what I do:
1. Build `go-linux-arm64-bootstrap-1.14.1.tbz` in an amd64 PC
2. Extract `go-linux-arm64-bootstrap-1.14.1.tbz` as `/data/go-linux-arm64-bootstrap-1.14.1/` in arm box
3. Add an option `GOLANG_BOOTSTRAP_BASE_DIR` to `lang/golang/golang/Makefile`
4. Add `CONFIG_GOLANG_BOOTSTRAP_BASE_DIR="/data/go-linux-arm64-bootstrap-1.14.1"` to `.config` in SDK in arm box
After doing that, building golang app no longer failed with `go-bootstrap cannot be installed on linux/arm64. Stop.`.
**BUT** there are two problem not resolved:
- If remove the line after `define Host/Compile` ie **`# Build GO`**, build will stop with `extraneous 'endif'. Stop.`
- If `CONFIG_GOLANG_BOOTSTRAP_BASE_DIR` is set to empty, building golang app not stop at `go-bootstrap cannot be installed on linux/arm64`.
Any help @jefferyto ?
---
Here is what I do to `lang/golang/golang/Makefile`:
```
diff --git a/lang/golang/golang/Makefile b/lang/golang/golang/Makefile
index dd50c2d32..b5d06b3ea 100644
--- a/lang/golang/golang/Makefile
+++ b/lang/golang/golang/Makefile
@@ -30,6 +30,17 @@ PKG_BUILD_DIR:=$(BUILD_DIR)/go-$(PKG_VERSION)
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0
+define Package/golang/config
+ menu "Configuration"
+
+ config GOLANG_BOOTSTRAP_BASE_DIR
+ string
+ prompt "golng bootstrap base directory"
+ default ""
+
+ endmenu
+endef
+
PKG_GO_WORK_DIR:=$(PKG_BUILD_DIR)/.go_work
PKG_GO_HOST_CACHE_DIR:=$(PKG_GO_WORK_DIR)/host_cache
PKG_GO_TARGET_CACHE_DIR:=$(PKG_GO_WORK_DIR)/target_cache
@@ -62,9 +73,13 @@ BOOTSTRAP_SOURCE:=go1.4-bootstrap-20171003.tar.gz
BOOTSTRAP_SOURCE_URL:=$(GO_SOURCE_URLS)
BOOTSTRAP_HASH:=f4ff5b5eb3a3cae1c993723f3eab519c5bae18866b5e5f96fe1102f0cb5c3e52
+ifeq ($(CONFIG_GOLANG_BOOTSTRAP_BASE_DIR),)
BOOTSTRAP_BUILD_DIR:=$(HOST_BUILD_DIR)/.go_bootstrap
BOOTSTRAP_WORK_DIR:=$(BOOTSTRAP_BUILD_DIR)/.go_work
BOOTSTRAP_CACHE_DIR:=$(BOOTSTRAP_WORK_DIR)/cache
+else
+BOOTSTRAP_BUILD_DIR:=$(CONFIG_GOLANG_BOOTSTRAP_BASE_DIR)
+endif
BOOTSTRAP_GO_VALID_OS_ARCH:= \
darwin_386 darwin_amd64 \
@@ -153,31 +168,41 @@ define Download/golang-bootstrap
URL:=$(BOOTSTRAP_SOURCE_URL)
HASH:=$(BOOTSTRAP_HASH)
endef
-$(eval $(call Download,golang-bootstrap))
+ifeq ($(CONFIG_GOLANG_BOOTSTRAP_BASE_DIR),)
+$(eval $(call Download,golang-bootstrap))
$(eval $(call GoCompiler/AddProfile,Bootstrap,$(BOOTSTRAP_BUILD_DIR),,bootstrap,$(GO_HOST_OS_ARCH)))
+endif
+
$(eval $(call GoCompiler/AddProfile,Host,$(HOST_BUILD_DIR),$(HOST_GO_PREFIX),$(HOST_GO_VERSION_ID),$(GO_HOST_OS_ARCH)))
$(eval $(call GoCompiler/AddProfile,Package,$(PKG_BUILD_DIR),$(GO_TARGET_PREFIX),$(GO_TARGET_VERSION_ID),$(GO_OS_ARCH)))
define Host/Prepare
$(call Host/Prepare/Default)
+ ifeq ($(CONFIG_GOLANG_BOOTSTRAP_BASE_DIR),)
mkdir -p $(BOOTSTRAP_BUILD_DIR)
$(BOOTSTRAP_UNPACK)
+ endif
endef
define Host/Compile
+ # Build GO
+ ifeq ($(CONFIG_GOLANG_BOOTSTRAP_BASE_DIR),)
$(call GoCompiler/Bootstrap/CheckHost,$(BOOTSTRAP_GO_VALID_OS_ARCH))
+ endif
$(call GoCompiler/Host/CheckHost,$(HOST_GO_VALID_OS_ARCH))
mkdir -p \
$(BOOTSTRAP_CACHE_DIR) \
$(HOST_GO_CACHE_DIR)
+ ifeq ($(CONFIG_GOLANG_BOOTSTRAP_BASE_DIR),)
$(call GoCompiler/Bootstrap/Make, \
GOCACHE=$(BOOTSTRAP_CACHE_DIR) \
CC=$(HOSTCC_NOCACHE) \
CXX=$(HOSTCXX_NOCACHE) \
)
+ endif
$(call GoCompiler/Host/Make, \
GOROOT_BOOTSTRAP=$(BOOTSTRAP_BUILD_DIR) \
```
dsouza
October 21, 2024, 5:16pm
4
I believe I need to set GOLANG_EXTERNAL_BOOTSTRAP_ROOT
to the directory where go is in my system (/usr/lib/go).
However I am not able to find where I should set GOLANG_EXTERNAL_BOOTSTRAP_ROOT=/usr/lib/go
Any hint would be appreciated.
dsouza
October 25, 2024, 6:52pm
5
OK, found it. How to solve - after setting up the build environment , doing all the pre-build steps , right after running make menuconfig
and before starting the build do this:
Install go in your build environment:
sudo apt install golang
Find where it is installed:
whereis go
. In my case it was installed in /usr/bin/go
Edit your OpenWrt build .config:
nano .config
Find and change the following configuration:
CONFIG_GOLANG_EXTERNAL_BOOTSTRAP_ROOT="/usr/lib/go"
Done! Now the build can be started (make -j9
in OrangePi) and it will not fail in the GoLang phase.
3 Likes
system
Closed
November 4, 2024, 6:53pm
6
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.