Self-contained applications in Linux are not truly portable
Steps to reproduce
- create self-contained application (Ubuntu runtime)
- dotnet restore
- dotnet publish
- ldd -v
- for each dynamic dependency, copy and link locally (in the publish folder), e.g.: cp /usr/lib/x86_64-linux-gnu/libunwind.so.8.0.1 . ln -s libunwind.so.8.0.1 libunwind.so.8 cp /usr/lib/x86_64-linux-gnu/libunwind-x86_64.so.8 .
- find the loader listed in the ldd output, and copy locally (in the publish folder), e.g.: ll /lib64/ld-linux-x86-64.so.2 cp /lib/x86_64-linux-gnu/ld-2.19.so .
- create a tarball with the output of publish + dependencies as above
- copy this tarball to another distro
- execute using: LD_LIBRARY_PATH=.
e.g.: D_LIBRARY_PATH=. ./ld-2.19.so ./myapp ./myapp.dll
Expected behavior
Since Linux guarantees kernel api compatibility across versions, it should be possible to package all userspace dependencies and libraries, and package them in this way to create a portable application. The executable should run successfully using the original loader.
Actual behavior
Failed to initialize CoreCLR, HRESULT: 0x80131500
Trace shows that the process name is taken from the loader and used to determine the name of the assembly to load, which does not exist:
Own DLL path=[/.../ld-2.19.so.dll]
Environment data
dotnet --info output:
.NET Command Line Tools (1.0.0-rc2-002678)
Product Information: Version: 1.0.0-rc2-002678 Commit Sha: 3b2ea9d14b
Runtime Environment: OS Name: ubuntu OS Version: 14.04 OS Platform: Linux RID: ubuntu.14.04-x64
Dotnet version: 1.0.0-rc2-002678 Built against kernel: 3.19.0-58-generic
Target kernels tested for execution:
Centos6 [2.6.32-573.18.1.el6.x86_64] Centos7 [3.10.0-327.10.1.el7.x86_64] SLES11 [3.0.101-71-default]
Please assign to @schellap
/cc @schellap
@blackdwarf, this is a topic for discussion. What are we promising with respect to app portability? @hglkrijger is trying to take a published standalone app to another distro (another rid) and manually copying over the other dynamic dependencies (what we mark as pre-requisites) of the app.
This is at best unsupported because it breaks the invariant of:
- Using the published executable as the activator -- instead the dynamic linker (
ld-linux.so*) is used to load the executable like:
./ld-linux.so* app* <managed-args>
# this breaks our notion of the process name because the process is not dotnet* or app* but ld-linux.so*
- Also, standalone apps are designed to be executed on the same or compatible rid that the app is being published for. Note that the conformance is at the NuGet "rid" level.
- Can "rid" compatibility be equated to kernel compatibility? I doubt that because, AFAIK, we don't guarantee ubuntu 14.04 to ubuntu 16.04 compatibility.
If an user wants to migrate to different platforms, I would consider using the Shared Framework and make their application a portable application by retaining the "type": "platform" in the project.json
Cc @piotrpMSFT @davidfowl @gkhanna79
I'm moving this out of preview-2.
@schellap let's chat tomorrow, I need to understand some more what is happening here. The loading logic...is it like that because the host is not built for all distros that this is supposed to run on?
RID compat is not kernel compat, that is, it doesn't imply that.
Any updates on this?
Hey guys, is there any work done with regards to this?
@hglkrijger @blackdwarf @gkhanna79 @krwq @schellap
I'm really looking forward to create some applications using dotNET core, it'd be great help if you could provide some insights.
@abhi18av what is the insight you are looking for? This issue describes a very special approach to having a self-contained deployment that also carries with it .NET Core's native dependencies. Is this what you had in mind or something else?
I just wanted to probe the idea whether I'd able to create xwt or gtk# applications based on dotNET core. The article you pointed me to, was helpful but I'd like to know your opinion about it.
The runtime has done considerable work to change how they reference native dependencies. This should be addressed now.