Support statically linked NativeAOT distribution#448
Support statically linked NativeAOT distribution#448hez2010 wants to merge 16 commits intodotpcap:masterfrom
Conversation
Codecov Report❌ 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. 🚀 New features to boost your workflow:
|
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 <kayoub5@live.com>
|
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 |
SystemOperatingAPIs 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.