Conversation
|
Forgive my frankness, but this PR is adding unprecedented complexity to the build. For proprietary builds of various distributions, using CGO is a given fact. This PR wants to cover all possible CGO builds, which doesn't seem very necessary. I think it's unnecessary to make a big fuss over a rare DNS resolution issue; a document explanation or emphasis would suffice. |
|
@douglarek 从用户的角度来说,如果没有安装两个工具,行为是和之前一样的,不是强制的。只是尽量在工具存在的情况下绕过glibc进行静态编译 |
|
@douglarek CGO_ENABLED=0 可能会带来其他潜在问题,另外由关闭 cgo 导致的 dns 解析失败的问题很难排查,考虑到用户的环境复杂度,使用 libc 而不是 pure go 实现将问题复杂度从用户转移给更为专业的打包者我认为是可接受的。 |
How about outputting whether a cgo is enabled in the version information? like this: if not: |
|
@douglarek What about the following compromise:
|
I think this is quite good; the binary released by the project can make such guarantees. However, when it comes to users compiling on their own, they can decide for themselves. |
|
Numb, it seems that enabling CGO on amd64 causes node domain name resolution issues.
|
| ifdef CGO_ENABLED_NDEF | ||
| export CGO_ENABLED := 0 | ||
| endif |
There was a problem hiding this comment.
| ifdef CGO_ENABLED_NDEF | |
| export CGO_ENABLED := 0 | |
| endif | |
| export CGO_ENABLED ?= 0 |
| ifeq ($(CGO_ENABLED),0) | ||
| ifdef GOARCH_NDEF | ||
| ifeq ($(CC),cc) | ||
| ifneq ($(shell which musl-gcc),) |
There was a problem hiding this comment.
Using command -v is better than which when checking the existence of executable, as it is a UNIX-compatible built-in command.
Reference: https://stackoverflow.com/questions/592620/how-can-i-check-if-a-program-exists-from-a-bash-script
| ifneq ($(shell which musl-gcc),) | |
| ifneq ($(shell command -v musl-gcc),) |
| ifeq ($(CC),cc) | ||
| ifneq ($(shell which musl-gcc),) | ||
| export CC := musl-gcc | ||
| else ifneq ($(shell which zig),) |
There was a problem hiding this comment.
| else ifneq ($(shell which zig),) | |
| else ifneq ($(shell command -v zig),) |
| $(info ! CGO_ENABLED=0 is not recommended. Please consider to install musl-gcc for static link instead. See https://github.com/daeuniverse/dae/issues/557) | ||
| endif | ||
| endif | ||
| else ifneq ($(shell which zig),) |
There was a problem hiding this comment.
| else ifneq ($(shell which zig),) | |
| else ifneq ($(shell command -v zig),) |
There was a problem hiding this comment.
command -v 在 /bin/sh 能用吗
reproduced on my machine |
Background
根据 #557 所述,应尽量开启 CGO。对于跨平台移植性,使用 static link 来保证。因此检查 musl-gcc 和 zig 的可用性并调整 CC 进行 static link。
Checklist
Full Changelogs
Issue Reference
Closes #557
Test Result