Skip to content
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

[IMPROVEMENT] Disable CGO in longhorn components if not used #7135

Closed
derekbit opened this issue Nov 17, 2023 · 4 comments
Closed

[IMPROVEMENT] Disable CGO in longhorn components if not used #7135

derekbit opened this issue Nov 17, 2023 · 4 comments
Assignees
Labels
kind/improvement Request for improvement of existing function priority/0 Must be implement or fixed in this release (managed by PO) require/auto-e2e-test Require adding/updating auto e2e test cases if they can be automated require/backport Require backport. Only used when the specific versions to backport have not been definied. require/doc Require updating the longhorn.io documentation
Milestone

Comments

@derekbit
Copy link
Member

Is your improvement request related to a feature? Please describe (👍 if you like this request)

The CGO support is enabled by default (ref). In general, longhorn components except for longhorn-engine don't need CGO.

To avoid the warnings, disable CGO in longhorn components if not used.

/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: /tmp/go-link-3682899690/000020.o: in function `mygetgrouplist':
/usr/local/go/src/os/user/getgrouplist_unix.go:18:(.text+0x1e): warning: Using 'getgrouplist' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: /tmp/go-link-3682899690/000019.o: in function `mygetgrgid_r':
/usr/local/go/src/os/user/cgo_lookup_unix.go:40:(.text+0x32): warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: /tmp/go-link-3682899690/000019.o: in function `mygetgrnam_r':
/usr/local/go/src/os/user/cgo_lookup_unix.go:45:(.text+0x73): warning: Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: /tmp/go-link-3682899690/000019.o: in function `mygetpwnam_r':
/usr/local/go/src/os/user/cgo_lookup_unix.go:35:(.text+0xb3): warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: /tmp/go-link-3682899690/000019.o: in function `mygetpwuid_r':
/usr/local/go/src/os/user/cgo_lookup_unix.go:30:(.text+0xf2): warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: /tmp/go-link-3682899690/000004.o: in function `_cgo_3c1cec0c9a4e_C2func_getaddrinfo':
/tmp/go-build/cgo-gcc-prolog:58:(.text+0x33): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

Describe the solution you'd like

Describe alternatives you've considered

Additional context

@derekbit derekbit added require/auto-e2e-test Require adding/updating auto e2e test cases if they can be automated require/doc Require updating the longhorn.io documentation kind/improvement Request for improvement of existing function require/backport Require backport. Only used when the specific versions to backport have not been definied. labels Nov 17, 2023
@derekbit derekbit added this to the v1.6.0 milestone Nov 17, 2023
@innobead innobead added the priority/0 Must be implement or fixed in this release (managed by PO) label Nov 29, 2023
@derekbit
Copy link
Member Author

derekbit commented Dec 6, 2023

In scripts/build of longhorn componenets, -linkmode external -extldflags -static are added to LINKFLAGS by default.
However, libc doesn't support static linking. Two solutions

  • Disable CGO if a componet doesn't need CGO
  • Use musl-libc that supports static linking

@derekbit
Copy link
Member Author

derekbit commented Dec 8, 2023

longhorn-engine and longhorn-instance-manager are using CGO because of libcow2.

@longhorn-io-github-bot
Copy link

longhorn-io-github-bot commented Dec 8, 2023

Pre Ready-For-Testing Checklist

  • Where is the reproduce steps/test steps documented?
    The reproduce steps/test steps are at:

run e2e test_rwx.py

  • Is there a workaround for the issue? If so, where is it documented?
    The workaround is at:

  • Does the PR include the explanation for the fix or the feature?

  • Does the PR include deployment change (YAML/Chart)? If so, where are the PRs for both YAML file and Chart?
    The PR for the YAML change is at:
    The PR for the chart change is at:

#7136

  • Have the backend code been merged (Manager, Engine, Instance Manager, BackupStore etc) (including backport-needed/*)?
    The PR is at

  • Which areas/issues this PR might have potential impacts on?
    Area: compilation
    Issues

@innobead
Copy link
Member

The PR has been merged. Let's observe if any issues over time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/improvement Request for improvement of existing function priority/0 Must be implement or fixed in this release (managed by PO) require/auto-e2e-test Require adding/updating auto e2e test cases if they can be automated require/backport Require backport. Only used when the specific versions to backport have not been definied. require/doc Require updating the longhorn.io documentation
Projects
Status: Closed
Development

No branches or pull requests

3 participants