-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Build: Support static linked executable #4152
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why need
SRS_STATIC_STD_CPP
? Maybe we should only supportSRS_STATIC
which leads to-static-libstdc++ -static
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-static
will generate a static linked executer,-static-libstdc++
only link the static libstdc++ library.So
-static
will cover-static-libstdc++
scope, I think it's no need to combine-static -static-libstdc++
together.https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the output if use
-static
without-static-libstdc++
? User only want a static binary without depends, majority of users can't understand the nuance of these two options.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Linux:
-static
output:The warning said:
dlopen
,getaddrinfo
andgethostbyname
requires libc similar runtime shared library to support.with both
-static -static-ibstdc++
same warning like
-static
.ldd ./objs/srs
same output:
not a dynamic executable
.git show 6314c27
on above commit,
SRS_STATIC
use-static-libstdc++
to replace-static
.But I think keep fully static linked exec can be an option, but not recommended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upon investigation, when we utilize certain functions such as dlopen and gethostbyname, we cannot achieve complete static linking, even though we use the -static flag; full static linking is not possible.
Only by removing the dependencies on these functions can we fully utilize the -static flag to create a version that truly does not depend on glibc.
Therefore, it is necessary to remove the dependencies on these functions. The dependency on dlopen comes from third-party libraries, which might be removed through compilation options. Functions like gethostbyname may require the use of different libraries or an implementation by the ST team itself.
https://stackoverflow.com/questions/15165306/compile-a-static-binary-which-code-there-a-function-gethostbyname
xmrig/xmrig#2902
https://www.reddit.com/r/haskell/comments/vqqq7x/comment/iez099a/
TRANS_BY_GPT4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To facilitate full static linking, we can only support the
-static
option, rather than also having a-static-libstdc++
option, which users might not understand how to use.Essentially, when we support
-static
, a multitude of warnings are generated. These warnings actually indicate potential issues, hence our support for-static
is not robust and leaves underlying problems unresolved.We absolutely cannot offer an option that carries potential risks, as it would make any arising issues even more difficult to address.
TRANS_BY_GPT4