Skip to content

Commit

Permalink
packages: update CGO_LDFLAGS for NVIDIA Go packages
Browse files Browse the repository at this point in the history
The way that Go 1.21 builds dynamicaly linked binaries changed from 1.20
and before. This doesn't export all the symbols and can result in a
panic when dynamically loaded. Adding in -export-dynamic to the
CGO_LDFLAGS tells the compiler to export all the symbols which provides
the needed lookups for these binaries.

Signed-off-by: Matthew Yeazel <[email protected]>
  • Loading branch information
yeazelm committed Dec 21, 2023
1 parent 53f322c commit ac12e49
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/ecs-gpu-init/ecs-gpu-init.spec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cp -r %{_builddir}/sources/%{workspace_name}/* .
%set_cross_go_flags
# We don't set `-Wl,-z,now`, because the binary uses lazy loading
# to load the NVIDIA libraries in the host
export CGO_LDFLAGS="-Wl,-z,relro"
export CGO_LDFLAGS="-Wl,-z,relro,-export-dynamic"
go build -buildmode=pie -ldflags="${GOLDFLAGS}" -o ecs-gpu-init ./cmd/ecs-gpu-init

%install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ BuildRequires: %{_cross_os}glibc-devel
%cross_go_configure %{goimport}
# We don't set `-Wl,-z,now`, because the binary uses lazy loading
# to load the NVIDIA libraries in the host
export CGO_LDFLAGS="-Wl,-z,relro"
export CGO_LDFLAGS="-Wl,-z,relro,-export-dynamic"
go build -ldflags="${GOLDFLAGS}" -o nvidia-device-plugin ./cmd/nvidia-device-plugin/

%install
Expand Down

0 comments on commit ac12e49

Please sign in to comment.