-
Notifications
You must be signed in to change notification settings - Fork 267
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
Support statically linked NativeAOT distribution #448
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #448 +/- ##
==========================================
- Coverage 82.14% 78.67% -3.48%
==========================================
Files 51 51
Lines 2823 2856 +33
Branches 312 312
==========================================
- Hits 2319 2247 -72
- Misses 383 503 +120
+ Partials 121 106 -15 ☔ View full report in Codecov by Sentry. |
Are you experiencing a specific error with NativeAOT, or is this just an optimization? Currently SharpPcap uses some runtime dynamic logic to detect so/dll filename, unfortunately there is no standard name that the code can be linked against in a cross platform way. |
Actually .NET doesn't care about the prefix |
I encountered unresolved symbols error from the linker (because some Windows-specific P/Invoke doesn't get trimmed away on Linux) after enable static linking in NativeAOT. By using |
In Ubuntu the so name is |
What symbols did you get an error for? |
I think the package manager will create a symbolic link |
The error message pointed to |
You can try to build https://github.com/hez2010/SysuSurf using |
the idea itself is ok, but the pr breaks CI, especially remote pcap. |
Will try to figure out a way to use wpcap on Windows and pcap on Linux to fix the ci. |
Is RPCAP a Windows-only feature? |
it works in windows (winpcap), and in Linux (requires a configuration flag during build) sharppcap/scripts/install-libpcap.sh Line 26 in 4c958ee
|
the dll name is wpcap.dll and not pcap.dll in windows, so standard donet library resolution logic won't work. |
Any reason you have to use |
Only with |
After passing |
Not sure why CI is still failing, seems like some unrelated timeout issue? |
Why do you want to statically link it in the first place? |
I want to run it on my router, which is hard to have all dependencies installed. So I would prefer to build a distroless binary which statically links everything and can run directly from scratch. |
Co-authored-by: Ayoub Kaanich <[email protected]>
As far as I see, using SharpPcap/LibPcap/LibPcapSafeNativeMethods.cs Other files should not affect the linker, and the ugly check is not needed. |
@kayoub5 It turns out that the NativeAOT toolchain doesn't care about the library name at all. So let's keep using |
SystemOperating
APIs on .NET 6+. The NativeAOT compiler can remove all branches that don't fit target operating system, so Windows-specific APIs won't be linked on Linux platform.