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
cmd/go: remove -buildmode=shared (not c-shared) #47788
Comments
This proposal has been added to the active column of the proposals project |
I really want to use this buildmode=shared mode. |
@rsc how has it been broken since modules? |
Just to clarify, this is not related to |
@electricface Why do you want to use it? Are you using it today? @scott-cotton You can't use @ainar-g Correct, this is not about |
@ianlancetaylor As other C or C++ programs are using shared-library, we are researching on some shared-library-like mechanism of golang. Inspired by After this commit, our "unoffical plugin" solution can work fine with go 1.14.9~1.16.7. Programs built in this way can run stably. But this won't work on go 1.17. Program will exit with a "fatal error: unreachable method called. linker bug?" Plan of remove |
@electricface It sounds like you want plugins, which are supported (though not very well) by |
@ianlancetaylor |
"I want to use it" is different from "I am using it today". |
Based on the discussion above, this proposal seems like a likely accept. |
Just to confirm, this proposal suggests to remove |
This proposal is only about |
No change in consensus, so accepted. 🎉 |
@rsc not sure if this is a good place to give feedback about the proposal process, but this is the first time (since the proposal process exists) that I missed an issue. I was mildly interested in this (not enough now to vehemently protest), but even if I'm subscribed to the proposal process issue and I normally read minutes every week, I missed this. I took 10 days off for vacation, and those 10 days covered the only 2 emails where this issue was mentioned, before today when it was approved. Again, I don't mind about this specific issue at this point but I wanted to raise a general point. Maybe a proposal should stay a minimum time in the proposal process before being closed, so that even people that don't work on Go full time have time to notice and react even with personal life happening in-between. |
To limit binary file size, I use command |
Our company has been using the |
Writing a wrapper around LGPL C libraries is a "work that uses the library." The C libraries can continue to be shared libraries. There is no need for the Go code itself to be in a shared library. That works today and will continue to work.
That is not our intent. It is fine for Go programs to use GPL libraries. It is fine for Go programs to use LGPL libraries, as shared libraries, if those libraries are written in other languages. It's true that it's hard for Go code to be licensed under the LGPL; it is in effect the same as being licensed uder the GPL. But that doesn't seem so bad as even the FSF recommends against using the LGPL (https://www.gnu.org/licenses/why-not-lgpl.html). The difficulty with shared libraries in Go is not because we don't like shared libraries. It's because they are technically difficult to support, and nobody has figured out how to do it well. And for what it's worth I'm a lot more than 46 years of age. |
@ianlancetaylor thanks for addressing our concern but, A solution would be directly using that C-shared library with cgo and avoid the wrapper the ultimate solution is just to write the entire LGPL/GPL code in Go
very well understood, Thank you |
Yes, but the Go wrapper is not a derivative of the C code, and as such the Go wrapper can be under a different license. The C code, under the LGPL, will be in a shared library, and the Go wrapper, not under the LGPL, will not. |
No sir, that's your technical opinion as an engineer, not a legal opinion LGPL defines these terms on its own legal universe, Basically, it means you cannot circumvent LGPL by actually writing another library and putting another license to it, doing the same thing, otherwise, this is possible with C, or other languages, if making a library in Go of a library of LGPL, it must be LGPL and be a library, the usage of LGPL directly does not fall under this (as I wrote), It is well understood legally an LGPL library must be dynamically linked or the application violates this, This is based on LGPL 2.1 otherwise 3.0 is even more difficult.
...
If Go does not support shared library for Go libraries, it is legally safe to say, not to write wrappers around LGPL C code and statically link it, it is very easy to show the user is violating LGPL |
That is correct. However, it is also my informed opinion due to having worked on free software licensing issues for decades. I was one of many people who contributed to the design of the LGPL in the first place.
Yes. In the scenario I described, the LGPL code continues to be dynamically linked. Absolutely nothing changes with respect to the LGPL code. No part of the LGPL code is modified in any way. It continues to be under the LGPL, it continues to be distributed as a dynamically linked shared library. It continues to be possible for the end user to substitute in a different version of the shared library when running the executable. |
Thanks My problem: Lawyers at our company: Neither GPL nor LGPL has been explicitly tested in a court of law, the linking issue subject to MySQL vs. NuSphere case was settled outside of the court. So we take the most conservative way; defending in court is too expensive. exceeding the boundaries of compliance to a license is not. |
Some folks contacted me from ITF USA Sending messages from process A (EULA or any license) to process B (GPL licensed), embracing 100% separation I guess that's doable, Thanks for @ianlancetaylor 's help and other folks for their input. |
@rsc Is there any issue or discussion to track about your My so far hypothetical use case is a multiprocess architecture, with a bunch of small helper programs that possibly depend on C libraries and can be installed separately. Again, it's about size. I get a feeling that Linux distributions could make use of a "go-rt" package for "std" and link their stuff against that. It would save a bit of bandwidth for utilities. |
I've been working on plugin loading and splitting components cleanly (and automatically) across multiple IPC-connected processes, the code is available here: controller-bus. It could sure use some improvement on the c-shared plugin loading side, (although I know that's unrelated to this issue) |
After reading this whole thread it's not clear to me about
|
@laoshaw There has not been a final decision but what you describe is likely. More precisely, it's likely that we will only permit a single |
Just wanted to check on the status of this. Since the issue is closed, is there another issue/location where I can follow the evolution of this? I don't see it explicitly in the 1.19 beta 1 change log so I'm guessing at best it'll be for 1.20? |
@mlaventure I think the status is that we developed an idea (a single shared library) but stalled out on implementing it. Nothing has changed yet and as far as I know there is no new proposal. |
@ianlancetaylor thanks for the update. Is there somewhere I can track the progress on this? In the meantime we'll just have to transition to a different language for our systems with stricter memory constraints unfortunately. |
@mlaventure I don't know of a place to track progress. Sorry. You should change to a different language if it makes sense for you, of course, but I don't understand the comment. The existing |
Unfortunately it doesn't work for me, the compiler panics when I try to build a package with
This is using go 1.17.11. |
You wouldn't normally use both |
That is #47455, which could perhaps be reopened — but, to be honest, I would be surprised if it gets much debugging effort until we figure out the future of |
It used to be the only way I had found to build a shared library and avoid the |
Change https://go.dev/cl/417194 mentions this issue: |
-buildmode=shared installs shared libraries into GOROOT and expects to reuse them across builds. Builds in module mode, however, each have their own set of dependencies (determined by the module's requirements), so in general cannot share dependencies with a single GOROOT. Ideally in the long term we would like to eliminate -buildmode=shared entirely (see #47788), but first we need a replacement for the subset of use-cases where it still works today. In the meantime, we should run these tests only in GOPATH mode. Non-main packages in module mode should not be installed to GOPATH/pkg, but due to #37015 they were installed there anyway, and this test heavily relies on installing non-main packages. For #37015. Change-Id: I7c5d90b4075d6f33e3505d6a8f12752309ae5c03 Reviewed-on: https://go-review.googlesource.com/c/go/+/417194 Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com>
-buildmode=shared installs shared libraries into GOROOT and expects to reuse them across builds. Builds in module mode, however, each have their own set of dependencies (determined by the module's requirements), so in general cannot share dependencies with a single GOROOT. Ideally in the long term we would like to eliminate -buildmode=shared entirely (see golang#47788), but first we need a replacement for the subset of use-cases where it still works today. In the meantime, we should run these tests only in GOPATH mode. Non-main packages in module mode should not be installed to GOPATH/pkg, but due to golang#37015 they were installed there anyway, and this test heavily relies on installing non-main packages. For golang#37015. Change-Id: I7c5d90b4075d6f33e3505d6a8f12752309ae5c03 Reviewed-on: https://go-review.googlesource.com/c/go/+/417194 Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com>
I've been looking at
The idea behind this is to enable updates to Go within the distribution without requiring mass rebuilds of applications due to stdlib patches/fixes. It has the side benefit of creating smaller binaries, but the gains are dependent on other factors as well (e.g. minimal dependencies). However, I do not fully understand the Go build process and the way the compiler works to know if this is even a feasible goal.
Does this sound like a use case that could be (or maybe shouldn't be at all) supported by Go tooling? |
@omenos, to my knowledge the Go compiler doesn't currently have any notion of “ABI boundaries”, and in particular it can do inlining of function bodies across packages. So there is a substantial risk of subtle bugs when picking up changes to the standard library and toolchain — particularly if a function fixed in a patch release was inlined into the caller when it was compiled. |
This sounds like a great solution. I know I'm late to the game and perhaps it's a bit much to ask ;) What would really help in my use case (single repo/module many separate applications) is a build command that can build multiple binaries in one go, and intelligently bundles all shared dependencies (or just anything not in their respective main packages) into a shared library. |
+1 for shared libraries support with module aware versions I'm using plugins with their dependencies. And they are very fat. I just want to move the dependencies to a shared library. And I don't want to care about a compatibility etc. Also, root installation is not acceptable for me too. Currently I'm using separate Go compiler (unlike /usr/lib/go). P.S. only linux + amd64, don't care any other OS or architecture |
-buildmode=shared has been broken since modules, and it is apparently unused.
See #47257 (comment).
Let's remove it.
The text was updated successfully, but these errors were encountered: