cmd/cgo: add #cgo CFLAGS and #CGO CXXFLAGS directives that only apply to files in the current package #40041
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
FeatureRequest
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
My situation is that instead of distributing static libraries, I have the C++ and C sources of the C package I'm wrapping stored in the same directory as my Go files, so that the package can in theory can be compiled on any C compiler.
In order to improve performance, I added a build tag which added the -flto flag, in order to enable link-time-optimization between all the C++ files.
However, I got an error when I added this line:
#CGO CFLAGS: -flto
to the file which implements LTO.
cannot load DWARF output from $WORK\b002\cgo.o: decoding dwarf section info a
t offset 0x0: too short
So I'd like a way to apply CFLAGS and CXXFLAGS to only the C and C++ files that are actually part of the package, and not CGO generated C files.
The text was updated successfully, but these errors were encountered: