New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: all: add GOARCHVERSION instead of "GOARM", "GOARM64", "GOAMD" & "GOAMD64" (etc..) #62129
Comments
It seems to me that the current approach also makes it straightforward to handle |
I guess there's a slight tension here between two different situations.
The current design favors 1. It does support 2, but it's annoying to implement in Bash (or similar) where there aren't flexible user-defined data types, and so representing a set of records (what might be a slice of a struct type in Go) is inconvenient. I'm sympathetic to that additional complexity, but if we put aside the limitations of Bash and chose a language with a more advanced type system then modelling the extra environment variables doesn't seem so awkward. For example, in Go: type BuildTarget struct {
OS string
Arch string
OtherEnv map[string]string
}
# ...
targets := []BuildTarget{
{
OS: "android",
Arch: "arm64",
},
{
OS: "android",
Arch: "arm64",
OtherEnv: map[string]string{
"GOARM64": "v2", // (I'm not sure what's actually valid for this particular environment variable)
},
},
// ...
} (Or even just a plain map of environment variables per build target, I suppose... |
You can dynamically create the environment variable name in Bash like so: # ...
variant="${parts[2]}"
# ...
env GOOS="${os}" GOARCH="${arch}" "GO$(tr '[:lower:]' '[:upper:]' <<< "${arch}")=${variant}" go build ... |
I apologize for any confusion, @ianlancetaylor. It seems there might be a slight misunderstanding regarding my proposal. When I inquire Golang itself about the platforms it supports via the My objective revolves around simplifying the process by utilizing a singular parameter for all architectures. For instance, while @apparentlymart, thank you for your precise response; it addressed my concern perfectly. As is the case with many others, I typically execute my build scripts in a shell/bash environment. Thus, I'm eager to streamline the compilation process for various architecture and version combinations. Unfortunately, achieving this isn't straightforward when considering compilation for different architectures and their respective versions. Upon executing the command
the output displays a comprehensive list of architectures, but it notably omits any version information associated with these architectures. While this output suffices for compiling Docker images due to Docker's automated handling of subversion compilation across all available architectures, it's essential to acknowledge that Docker and Golang operate differently, as was previously understood. Even tho this output is from golang it just works as I want it to when used with docker - how bizare. Addressing the issue raised in the discussion on GitHub (#62080), I specifically inquired about an effortless method to obtain a complete list of all feasible platforms that Golang can compile for, including architecture versions. Unfortunately, I haven't yet received a satisfactory response to my query, and the issue itself has since been closed. Subsequently, I devised my own approach to compilation, taking into consideration your insights, @apparentlymart. However, it's worth noting that when attempting to compile for multiple architectures and versions, the distinct parameters required for each combination introduce unnecessary complexity. This complexity could potentially prove unwieldy for developers, contrary to the developer-friendly ethos we aim to uphold. I find myself in agreement with @rittneje's suggestion, even though it might be considered a somewhat unconventional workaround. Admittedly, it does address a complexity that seems logically avoidable, given that the parameters denoting architecture versions could coexist harmoniously, even thou it is not a complete solution to the problem. Consequently, I propose a design wherein these diverse parameters (architectural versions) are consolidated under a unified parameter name. This shift could notably simplify the compilation process for multiple architectures and their respective versions, thereby enhancing the user experience and aligning with the principle of making developer tasks more accessible. Thank you for your attention and engagement in this matter. |
Building the tools for each possible |
On the other hand, if you want to be able to say |
The request you're describing aligns with the one I made here: #62080. I was seeking a solution to retrieve a comprehensive list of all feasible However, the current proposal at hand pertains to consolidating the distinct architecture versions under a singular parameter such as
I hold a differing perspective on this matter for several reasons:
Personally, I greatly value the ability to compile for all conceivable Implementing the Thank you for engaging in this discussion; your insights are appreciated. |
I think we all agree that this can be done regardless of whether we adopt this proposal. And I hope we all agree that we aren't going to drop the existing environment variables, as that would break existing scripts. So the question is whether there would be enough use of |
If we add GOARCHVERSION we still have to support the old GOAMD64 etc for existing build scripts. It doesn't seem worth having two at this point. Maybe if we were starting from scratch there'd be a conversation to have about GOARCHVERSION, but that ship has sailed, and it sailed to GOAMD64/GOARM64/etc island. |
This proposal has been declined as infeasible. |
I still disagree with this. I also remain confident that an adaptor could effectively handle both legacy To illustrate, I have prepared examples that address the specific points you raised: I will provide these examples for ALL platform values whose architecture may include a
For each case, I will demonstrate how the current legacy setup would look and compare it with the new one, along with the logical mapping. RULES:
The
Dockerfile:
AFAIK *OUTCOME_NEW=THE As evident, a proper mapping ensures 100% compatibility while maintaining the old way and introducing a new one. This allows developers to choose between using If one does not want to use any of this, just dont use Please consider this proposal, as it promises to simplify the lives of developers, offering enhanced convenience and backward compatibility. It also facilitates the maintenance of future platforms (for new upcomming Best regards, |
Here a simple golang snippet, that prints both out: The old way and the new one.
This is just a PoW of the Mapping and the rules. If you execute the programm it maps them like this: Output:
So
(after the mapping is done) |
Since I build my local golang binaries like this:
I noticed that I depending on the architecture the parameter to pass to the compiler would always differ - so it would be way more easy if we would have a general parameter to pass to the compiler, something like:
GOARCH_VERSION
The we could easily loop through something like this:
I guess this makes it more easy to compile for specific architectual versions - specially in batch.
Under the hood go then will automatically know that in the case of:
"linux/amd64/v3"
that
GOARCH_VERSION
basically isGOAMD64
and so the features ofGOAMD64=v3
should be applied.It would be awesome if we just could loop through "platforms" like in
docker buildx
.Yes I know this is not docker, but it is just way more easy to compile/build for all architectures & versions of them with docker and I would like to see this at go natively :)
The text was updated successfully, but these errors were encountered: