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

[x86/Linux] Cross building for x86 32bit on Linux #7006

Closed
92 of 99 tasks
seanshpark opened this issue Nov 17, 2016 · 20 comments
Closed
92 of 99 tasks

[x86/Linux] Cross building for x86 32bit on Linux #7006

seanshpark opened this issue Nov 17, 2016 · 20 comments
Labels
arch-x86 area-Meta os-linux Linux OS (any supported distro) port

Comments

@seanshpark
Copy link
Contributor

I would like to enable CoreCLR for 32bit x86 Linux based on the base with current Windows x86 codes.
I'm thinking this task to be in two stages. First is to fix all build errors and then to make it work properly with unit tests. Task items to do will be added to below lists. I hope compile will be done in both 32bit host native and 64bit host cross building.

Fix build error

Fix SOS build error (lucenticus)

Fix execution error

CoreFX

For CoreCLR, CoreFX and Core-Setup repos:

  • Add to cross targeting support in the build
  • Get Product build clean
  • Get Linux x86 packages generated
  • Enable CI support for build
  • Enable pipeline build support

Once the above is done, we should be able to produce .NET Core for Linux for x86 E2E.

@jkotas
Copy link
Member

jkotas commented Nov 18, 2016

@seanshpark Thanks a lot for getting the Linux x86 port started!

https://github.com/dotnet/coreclr/issues/1264 has earlier discussion on this. Look for replies that contain x86 - there are some useful tidbits.

cc @janvorli @gkhanna79

@gkhanna79
Copy link
Member

Thanks for looping me in @jkotas @seanshpark I took the liberty of adding few more specific items that I had followed when bringing up WinArm32 build.

@gkhanna79
Copy link
Member

Needless to say, I will be happy to help with bunch of these things.

@janvorli
Copy link
Member

@seanshpark awesome! Please feel free to ping me if you have any questions or need help with solving problems with coreclr, its PAL or native parts of CoreFX.

@seanshpark
Copy link
Contributor Author

Wow, thanks for the support! I got lots of things to study and learn and don't think I can do this by myself by looking at the updated task items :)
I just got the make files rough fixes so that CoreCLR builds with no errors last weekend on my local Linux machine but not executable yet. I'll try to make a PR one by one to fix the builds.
I've found some .asm translation needed to .S and also some inline asembly in .cpp files. And some files that can be copied from amd64.

@lucenticus
Copy link
Contributor

@seanshpark I just would like to share my brief investigation: I've succesfully built with your pull requests + disabled tests (with skiptests) + disabled libsosplugin + some hacks. But when I tried to run simple helloworld.exe, I got undefined symbol error for some symbols located in *.asm files. Probably, this information could be useful for you.

@seanshpark
Copy link
Contributor Author

I got undefined symbol error for some symbols located in *.asm files

@lucenticus , yes, there are lots of undefined symbols to fix and @parjong is currently working on it. Thanks for the share :) . I'll be working on the SOS.

@seanshpark
Copy link
Contributor Author

As there will be lots of unit test fix PRs, I think it is better not to add anymore PR items related with execution fixes... :)

@lucenticus
Copy link
Contributor

@seanshpark I've tried to run native 32bit build for CoreFX (using schroot) and found that init-tools.sh script downloads 64bit dotnet package only (https://github.com/dotnet/corefx/blob/master/init-tools.sh#L80). The same behavior has init-tools.sh from CoreCLR. It seems that we have to enable x86 support for https://github.com/dotnet/cli project in case we need native build (without cross)

@janvorli
Copy link
Member

janvorli commented Dec 8, 2016

@lucenticus enabling support for x86 Linux at this level should be the last step of the bringup, after everything works. It doesn't make sense to do it until you have fully functional coreclr. It is very preliminary to do it now. You can do native part of CoreFX build without it. You just need to run src/Native/build-native.sh instead of the root build.sh

@lucenticus
Copy link
Contributor

@janvorli Thanks a lot for suggestion! I'll use src/Native/build-native.sh script for that.

@gkhanna79
Copy link
Member

@seanshpark I just did a build of CoreCLR master on Linux Mint 18 (Ubuntu 16.04 based) as build.sh x86 and the generated binaries are all 64bit instead of x86 (readelf -h ./libcoreclr.so shows it to be ELF64). Is there a different way you have enabled the build?

@seanshpark
Copy link
Contributor Author

seanshpark commented Dec 9, 2016

@gkhanna79 , I use like this,

export NETCORE=$HOME/netcore

# build rootfs
sudo ROOTFS_DIR=$NETCORE/rootfs/x86-xenial ./cross/build-rootfs.sh x86 xenial

# build
ROOTFS_DIR=$NETCORE/rootfs/x86-xenial ./build.sh x86 debug cross clang3.8 skipnuget

@seanshpark
Copy link
Contributor Author

seanshpark commented Dec 9, 2016

And for a successful build you need to apply parjong:fix/x86_eh_macros (#8381) patch and disable SOS as some PRs are not merged yet. I use like this.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 702d177..df5cd5c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -531,7 +531,7 @@ if(CLR_CMAKE_PLATFORM_UNIX)
 endif(CLR_CMAKE_PLATFORM_UNIX)

 if(CLR_CMAKE_PLATFORM_UNIX)
-  add_subdirectory(src/ToolBox/SOS/lldbplugin)
+  #add_subdirectory(src/ToolBox/SOS/lldbplugin)
   if(NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
     add_subdirectory(src/pal)
   endif(NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d13e8f9..53cd3c3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -96,7 +96,7 @@ function(add_executable_clr)
 endfunction()

 if(CLR_CMAKE_PLATFORM_UNIX)
-  add_subdirectory(ToolBox/SOS/Strike)
+  #add_subdirectory(ToolBox/SOS/Strike)

   # Include the dummy c++ include files
   include_directories("pal/inc/rt/cpp")

@seanshpark
Copy link
Contributor Author

x86/Linux is now builds with repo itself and executes simple Hello World program.
you can test with building like this, (with Ubuntu 16.04 x64)

sudo ./cross/build-rootfs.sh x86 xenial
./build.sh x86 debug cross clang3.8 skipnuget

There are several big issues to solve, such as EH and reverse P/Invoke, and now concentrating on those.

@janvorli
Copy link
Member

@seanshpark it seems the skipnuget parameter is not needed, I was able to successfully build it without it. I didn't have to specify the clang3.8 either, the 3.6 was working just fine.

@gkhanna79
Copy link
Member

This is excellent progress! :)

@seanshpark
Copy link
Contributor Author

skipnuget parameter is not needed, ... the 3.6 was working just fine

thanks for the comment !

@seanshpark
Copy link
Contributor Author

I would like to close this issue and move remaining tasks to each projects as building for x86/Linux looks done and unit test results are shared in dotnet/coreclr#9265.

@janvorli
Copy link
Member

@seanshpark it makes sense

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-x86 area-Meta os-linux Linux OS (any supported distro) port
Projects
None yet
Development

No branches or pull requests

5 participants