Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
5fb8602c
Commit
5fb8602c
authored
Apr 16, 2015
by
Eric Paris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fall back to go build when static cgo not possible
Instead of just failing, use go build if people don't have the magic cgo stuff we need build-able/write-able.
parent
6d8a25ff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
golang.sh
hack/lib/golang.sh
+12
-9
No files found.
hack/lib/golang.sh
View file @
5fb8602c
...
...
@@ -247,11 +247,12 @@ kube::golang::place_bins() {
done
}
kube::golang::
exit_if_stdlib_not_installed
()
{
kube::golang::
fallback_if_stdlib_not_installable
()
{
local
go_root_dir
=
$(
go
env
GOROOT
)
;
local
go_host_os
=
$(
go
env
GOHOSTOS
)
;
local
go_host_arch
=
$(
go
env
GOHOSTARCH
)
;
local
cgo_pkg_dir
=
${
go_root_dir
}
/pkg/
${
go_host_os
}
_
${
go_host_arch
}
_cgo
;
if
[
-e
${
cgo_pkg_dir
}
]
;
then
return
0
;
fi
...
...
@@ -260,12 +261,13 @@ kube::golang::exit_if_stdlib_not_installed() {
return
0
;
fi
kube::log::status
"+++ Error. stdlib pkg with cgo flag not found."
;
kube::log::status
"+++ Error. stdlib pkg cannot be rebuilt since
${
go_root_dir
}
/pkg is not writable by
`
whoami
`
"
;
kube::log::status
"+++ Error. Make
${
go_root_dir
}
/pkg writable for
`
whoami
`
for a one-time stdlib install, Or"
kube::log::status
"+++ Error. Rebuild stdlib using the command 'CGO_ENABLED=0 go install -a -installsuffix cgo std'"
;
exit
0
;
kube::log::status
"+++ Warning: stdlib pkg with cgo flag not found."
;
kube::log::status
"+++ Warning: stdlib pkg cannot be rebuilt since
${
go_root_dir
}
/pkg is not writable by
`
whoami
`
"
;
kube::log::status
"+++ Warning: Make
${
go_root_dir
}
/pkg writable for
`
whoami
`
for a one-time stdlib install, Or"
kube::log::status
"+++ Warning: Rebuild stdlib using the command 'CGO_ENABLED=0 go install -a -installsuffix cgo std'"
;
kube::log::status
"+++ Falling back to go build, which is slower"
;
use_go_build
=
true
}
kube::golang::build_binaries_for_platform
()
{
...
...
@@ -276,12 +278,14 @@ kube::golang::build_binaries_for_platform() {
local
-a
nonstatics
=()
for
binary
in
"
${
binaries
[@]
}
"
;
do
if
kube::golang::is_statically_linked_library
"
${
binary
}
"
;
then
kube::golang::exit_if_stdlib_not_installed
;
statics+
=(
$binary
)
else
nonstatics+
=(
$binary
)
fi
done
if
[[
"
${#
statics
[@]
}
"
!=
0
]]
;
then
kube::golang::fallback_if_stdlib_not_installable
;
fi
if
[[
-n
${
use_go_build
:-}
]]
;
then
# Try and replicate the native binary placement of go install without
...
...
@@ -298,7 +302,6 @@ kube::golang::build_binaries_for_platform() {
fi
if
kube::golang::is_statically_linked_library
"
${
binary
}
"
;
then
kube::golang::exit_if_stdlib_not_installed
;
CGO_ENABLED
=
0 go build
-installsuffix
cgo
-o
"
${
output_path
}
/
${
bin
}
"
\
"
${
goflags
[@]
:+
${
goflags
[@]
}}
"
\
-ldflags
"
${
version_ldflags
}
"
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment