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

Add arm64 architecture #399

Merged
merged 9 commits into from
Jan 14, 2025
Merged

Add arm64 architecture #399

merged 9 commits into from
Jan 14, 2025

Conversation

larskanis
Copy link
Member

@larskanis larskanis commented Dec 15, 2024

This add rake tasks for building RubyInstaller-head for arm64. They use the ruby-head version provided by oneclick/rubyinstaller2-packages#21

In general the installed Ruby+Devkit is already quite usable, but there are currently several issues with the build:

  • The side-by-side DLL loading doesn't work. CLANG doesn't include a XML manifest like GCC, so that moving the DLLs to ruby_builtin_dlls doesn't work. This also affects bin/etc directory with OpenSSL certificates. Workaround is to copy DLLs and etc one level up.
    • This was difficult to solve and since it's too heavy to be backported, it is only applied to ruby-3.4 and ruby-head. See the attached commits.
  • Switching fibers crashs sometimes. This is for instance in ruby core make btest here. Currently one and the same coroutine switcher arm64 is used on Linux and Windows and although ABI is very similar, it probably needs to be adjusted for Windows like on x86/x64.
  • gem "tzinfo-data", platforms: %i[ windows jruby ] doesn't install the gem, since Ruby on Windows-Arm64 isn't recognized as windows platform.
  • sqlite3 gem doesn't install. It fails to configure builtin sqlite3 library. Workaround is gem install sqlite3 -- --enable-system-libraries.
  • nokogiri gem doesn't install. It fails to configure builtin libxml2 library. Workaround is gem install nokogiri -- --use-system-libraries.
  • The RubyInstaller-Devkit setup file is with 230 MByte twice as fat. Maybe because of LLVM. Needs to be investigated.
    • LLVM / clang needs a lot more disk space than gcc. There's not much to change for now. Probably gcc will be available for ARM64 in the future, then it could make sense to switch to it. For the time being the ARM installer will ship clang instead of gcc.

Rails already works:

grafik

Closes #362

@johnnyshields
Copy link

johnnyshields commented Jan 2, 2025

@larskanis thanks for your great work on this!!

I've raised the PR for Rubygems/Bundler here: https://github.com/rubygems/rubygems/pull/8378/files to support ruby_arch = aarch64-mingw-ucrt (and mingw generically)

@larskanis larskanis force-pushed the arm64 branch 3 times, most recently from 2ba8851 to 6078b89 Compare January 8, 2025 19:49
Name the arm package only "arm" instead of arm64, since there is no Windows for arm 32 bit.

Install to c:/Ruby34-arm by default
…on.so file

So far ruby.exe and rubyw.exe contained a process-global manifest for side-by-side loading.
This way the DLLs bundled to RubyInstaller could be moved to a dedicated directory, so that they aren't loaded accidently by other apps because they are in the PATH.

It was introduced in b2bd630
The downside of a global manifest is that the dependent DLLs are always preferred over other DLL versions with the same name.
This caused for instance openssl.gem to fail, when the libssl DLL linked at build time was newer than the libssl bundled with RubyInstaller.

This patch introduces manifests per extension.so file with dedicated private dependencies.
This way the bundled openssl.so is directly linked to it's own libssl.dll by an embedded manifest.
It's similar to static linking libssl into openssl.so, but it allows to use unchanged libssl.dll from MINGW packages.

If a new openssl.gem version is installed per "gem install openssl", it links to MSYS2/MINGW packages at build time.
Since the resulting openssl.so doesn't contain the manifest, it also links to the MINGW packages at run time.

Patching extension.so files requires to add all single files recursively as file tasks.

Fixes #60
With the latest changes to rubyinstaller-packages, the ruby-core manifests are stored in the exe files.
It's then sufficient to add manifests to the DLLs bundled to rubyinstaller, in order to declare the dependencies.
It was moved in ruby-3.2 to etc/ssl and short time later to bin/etc/ssl because of changes in MSYS2-MINGW.
Both directory names are suboptimal.
Now we have to move the libssl.dll, due to the SxS changes, so that the certs directory would change another time.
To avoid another move this is now solved with a link (junction) to the original directory ruby/ssl .

Downside is that mklink always creates a junction with absolute path, even when only a relative path is given to the command.
It also needs a NTFS drive.
When the ruby installation is moved to a USB stick, then the CA certs are no longer found.
It can be manually fixed by moving the certs directory ruby/ssl into ruby/lib/ruby/<vers>/etc .
@larskanis larskanis force-pushed the arm64 branch 3 times, most recently from 10a3042 to c9db38d Compare January 9, 2025 09:36
Add DLL search path for legacy.dll loading libcrypto.dll and libcrypto.dll loading zlib.dll .
Adding file tasks within a rake tasks doesn't work.
Dependencies must be defined prior to running the rake resolver.
It also had the downside of priting too many log messages.

Implementing own cp_r which invokes tasks definitions is the better solution.
@larskanis larskanis force-pushed the arm64 branch 4 times, most recently from 98ad477 to ae90b30 Compare January 14, 2025 18:18
It it too heavy to be introduced in stable releases.

The creation of the junction file for OpenSSL is backported to Ruby-3.2.x and 3.3.x but it links to the old destination /bin/etc/ssl there.
This should ease the transition to ruby-3.4 and makes the documentation unifrom.
@larskanis larskanis merged commit a790d77 into master Jan 14, 2025
10 of 20 checks passed
@larskanis larskanis deleted the arm64 branch January 14, 2025 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add installer for windows-arm64
2 participants