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

[SR-124] Port Swift to Linux x86 32-bit #42746

Open
gribozavr opened this issue Dec 7, 2015 · 22 comments
Open

[SR-124] Port Swift to Linux x86 32-bit #42746

gribozavr opened this issue Dec 7, 2015 · 22 comments
Labels
compiler The Swift compiler in itself feature A feature request or implementation Linux Platform: Linux platform support

Comments

@gribozavr
Copy link
Collaborator

Previous ID SR-124
Radar rdar://problem/19035586
Original Reporter @gribozavr
Type New Feature
Additional Detail from JIRA
Votes 6
Component/s Compiler
Labels New Feature, Linux, NewPortRequest
Assignee None
Priority Medium

md5: 38bf3e8bffbcd48ecf45dbb1c6996fe5

Issue Description:

Right now Swift only targets 64-bit x86. A 32-bit port might be interesting.

@swift-ci
Copy link
Collaborator

Comment by Isaac Gouy (JIRA)

Yes please, there still is an Ubuntu 15.10 labelled: "32-bit – for machines with less than 2GB RAM"

@swift-ci
Copy link
Collaborator

Comment by Vivek Pandya (JIRA)

I am starting with setting up required development environment and compiling swift on 32 bit ubuntu 14.04 LTS.

@swift-ci
Copy link
Collaborator

Comment by Vivek Pandya (JIRA)

I change build-script-impl so that I can build for Linux-i686 case. It successfully build cmark , llvm . But it can not link clang . I used gold instead of ld but I came to know that mmap is not able to allocate a huge memory area around 1.5GB while linking , so linking of clang 3.8 failed.
I am using Ubuntu 14.04 on virtual box. According to /proc/cpuinfo it does not support hugepage size of 1GB . However virtual address is of 48 bits . Is it due to virtual box or 32 bit host can not support hugepagesize of 1GB ? My vm RAM is around 10 GB.
Please suggest any further step.

@gribozavr
Copy link
Collaborator Author

Enabling hugepages in the kernel won't solve the issue, you also need a linker that can make use of them.

I think you can achieve success in this project easier with cross-compilation from a 64-bit kernel. You'd need to cross-compile swift compiler itself, and the libraries. The swift compiler would be native 32-bit.

@swift-ci
Copy link
Collaborator

Comment by Vivek Pandya (JIRA)

I have read about similar problem for android-kernel compilation and for them hugepages has solved the issue. The gold linker may use it.
For the cross-compile option I have a doubt :

  1. What if some one don't have 64-bit kernel available ? How they will be compiling it?

@gribozavr
Copy link
Collaborator Author

They won't be compiling it, they would be using a pre-compiled package.

@swift-ci
Copy link
Collaborator

Comment by Vivek Pandya (JIRA)

For cross compiling should I temporarily set NATIVE_TOOLS_DEPLOYMENT_TARGETS = linux-i686 ? I read in the build-script-impl that for cross compiled tools it will compile for 2 times.

@swift-ci
Copy link
Collaborator

Comment by Vivek Pandya (JIRA)

while Cross compiling through 64 bit kernel I am getting error. It compiles llvm cmark and swift successfully for x86_64 arch but then it tries to build for i686 arch and llvm still refers to macosx version of table-gen due to this code:
if [[ $(is_cross_tools_deployment_target $deployment_target) ]] ; then

  1. FIXME: don't hardcode macosx-x86_64.
    cmake_options=(
    "${cmake_options[@]}"
    -DLLVM_TABLEGEN=$(build_directory macosx-x86_64 llvm)/bin/llvm-tblgen
    -DCLANG_TABLEGEN=$(build_directory macosx-x86_64 llvm)/bin/clang-tblgen
    )
    fi
    I tried to change it to
    if [[ $(is_cross_tools_deployment_target $deployment_target) ]] ; then

  2. FIXME: don't hardcode macosx-x86_64.
    cmake_options=(
    "${cmake_options[@]}"
    -DLLVM_TABLEGEN=$(build_directory linux-x86_64 llvm)/bin/llvm-tblgen
    -DCLANG_TABLEGEN=$(build_directory linux-x86_64 llvm)/bin/clang-tblgen
    )
    fi
    but still it points to macosx. Please help !

@modocache
Copy link
Mannequin

modocache mannequin commented Jan 4, 2016

vivekvpandya (JIRA User), can you tell me the exact invocation you used to cross-compile? I'd like to work on getting rid of those FIXMEs in the build script, and it would help to know exactly which arguments you're passing it. Thanks!

@swift-ci
Copy link
Collaborator

swift-ci commented Jan 4, 2016

Comment by Vivek Pandya (JIRA)

Hi Brain Ivan Gesiak ,
Actually I have added case to switch statement to handle 'linux-i686' target. Also done some changes in function to handle 'linux-i686' cross compile target then I have set default value for 'cross-compile-tool-deplyment-targets' to 'linux-i686'. Actually I should pass this value as option while invoking the build-script. If you want to see other changes I can post changed build-script-impl code to gist.
Thanks !

@modocache
Copy link
Mannequin

modocache mannequin commented Jan 4, 2016

> If you want to see other changes I can post changed build-script-impl code to gist.

Please do! Would love to get on the same page.

@swift-ci
Copy link
Collaborator

swift-ci commented Jan 4, 2016

Comment by Vivek Pandya (JIRA)

here is my build-script-impl gist https://gist.github.com/vivekvpandya/371ea611ab03c9bfc35b
please let me know if I can make progress in this project.

@modocache
Copy link
Mannequin

modocache mannequin commented Jan 4, 2016

Thanks, vivekvpandya (JIRA User)!

Just a note: you can specify cross-compile-tools-deployment-targets on the command-line, without hardcoding a default in the script itself. You can do this by passing build-script-impl arguments, which come after a --. For example:

$ utils/build-script -R -- --cross-compile-tools-deployment-targets="linux-i686"

I don't have any insight on the rest of your changes. I'm also interesting in supporting cross-compilation in the build script--we should exchange notes here or in a new issue.

@swift-ci
Copy link
Collaborator

swift-ci commented Jan 4, 2016

Comment by Vivek Pandya (JIRA)

I see that you are working on merging build-script and build-impl-script. I will give one more try to cross-compile. In mean time let me know if I can help you in merging build-script , build-impl-script.

@swift-ci
Copy link
Collaborator

swift-ci commented Jan 6, 2016

Comment by Vivek Pandya (JIRA)

If any one trying to cross-compile swift for 32 bit Linux from 64 bit version , I would suggest to download 32 bit version of libstdc++ and other required libs and make sure that clang -m32 is able to compile and link a 32 bit ELF binary.

@swift-ci
Copy link
Collaborator

swift-ci commented Oct 7, 2016

Comment by Chris Donnelly (JIRA)

Can anyone confirm otherwise? My understanding is there is still no i686 build in the wild, and that current build functions fail ungracefully for these machines. The current comments here from January do not seem to assist in 3.0 release. Would love to see the releases broaden to support both 32bit linux and ppc to name just two.

@swift-ci
Copy link
Collaborator

swift-ci commented Mar 9, 2017

Comment by Maksim Rogov (JIRA)

Would like to see a 32bit port as well.

@swift-ci
Copy link
Collaborator

Comment by Lescai Ionel (JIRA)

Any news on this?

@swift-ci
Copy link
Collaborator

swift-ci commented Mar 8, 2018

Comment by Lescai Ionel (JIRA)

   gigi@gigi-VirtualBox:~$ arch
i686
gigi@gigi-VirtualBox:~$ uname -a
Linux gigi-VirtualBox 4.13.0-36-generic #​40~16.04.1-Ubuntu SMP Fri Feb 16 23:26:51 UTC 2018 i686 i686 i686 GNU/Linux
gigi@gigi-VirtualBox:~$ local/Source/apple/build/Ninja-ReleaseAssert/swift-linux-i686/bin/swiftc hello.swift 
gigi@gigi-VirtualBox:~$ ./hello 
Hello, Swift!
gigi@gigi-VirtualBox:~$ 

Got it working with apple/swift from December and latest libdispatch repo. Have errors after from master, but I'll tackle them after I make a PR with the current changes.

@swift-ci
Copy link
Collaborator

Comment by Rex Fenley (JIRA)

ionel.lescai (JIRA User) any updates? Did your PRs make it through?

@swift-ci
Copy link
Collaborator

Comment by Lescai Ionel (JIRA)

rexmas (JIRA User), no. Haven't had time to work on it anymore. Here's the PR: apple/swift-corelibs-libdispatch#345 ... Didn't have a chance to make PRs for my changes on apple/swift, and they didn't work with HEAD anyway 🙁

Here's my branch: https://github.com/ionel71089/swift/tree/ubuntu32

@swift-ci
Copy link
Collaborator

Comment by Rex Fenley (JIRA)

Ah, thanks for sharing. I haven't worked with the compiler before, but I'll take a look and see if I can do anything useful, worth a shot.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added feature A feature request or implementation platform support and removed new feature labels Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself feature A feature request or implementation Linux Platform: Linux platform support
Projects
None yet
Development

No branches or pull requests

3 participants