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

Feat: Upgrade to Ruby 3.1.2 / Support ARM64 OSX/Linux #132

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/linux/runtime
/linux/output
/linux/traveling-ruby-gems*
/osx/runtime
/osx/output
/osx/work
/windows/cache
/windows/output
*.sublime-workspace
*.tar.gz
.DS_Store
2 changes: 1 addition & 1 deletion BUNDLER_VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.17.3
2.3.17
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@

Traveling Ruby is a project which supplies self-contained, "portable" Ruby binaries: Ruby binaries that can run on any Linux distribution and any macOS machine. It also has Windows support [(with some caveats)](#caveats). This allows Ruby app developers to bundle these binaries with their Ruby app, so that they can distribute a single package to end users, without needing end users to first install Ruby or gems.

_Note:_ - This is a fork, which currently supports the following platforms and versions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line can be removed.


| OS | Ruby | Architecture | Supported |
| -------| ------- | ------------ | --------- |
| OSX | 3.1.2 | x86_64 | βœ… |
| OSX | 3.1.2 | aarch64 (arm)| βœ… |
| Linux | 3.1.2 | x86_64 | βœ… |
| Linux | 3.1.2 | aarch64 (arm)| βœ… |
| Windows| 3.1.2 | x86_64 | βœ… |
| Windows| 3.1.2 | aarch64 (arm)| ❌ |

[![](https://raw.githubusercontent.com/FooBarWidget/traveling-ruby/main/doc/video.png)](https://vimeo.com/phusionnl/review/113827942/ceca7e70da)

_Introduction in 2 minutes_
Expand Down Expand Up @@ -38,7 +49,7 @@ This makes the release process much simpler. Instead of having to create almost

However, distributing a precompiled Ruby interpreter that works for all end users, is more easily said than done. [Read this section](#why_precompiled_binary_difficult) to learn why it's difficult.

Traveling Ruby aims to solve the problem of supplying precompiled **Ruby 2.4** binaries that work for all end users.
Traveling Ruby aims to solve the problem of supplying precompiled **Ruby 3.1** binaries that work for all end users.

## Getting started

Expand Down Expand Up @@ -81,7 +92,7 @@ Windows support:
* Traveling Ruby supports creating packages *for* Windows, but it does not yet support creating packages *on* Windows. That is, the Traveling Ruby tutorials and the documentation do not work when you are a Ruby developer on Windows. To create Windows packages, you must use macOS or Linux.

This is because in our documentation we make heavy use of standard Unix tools. Tools which are not available on Windows. In the future we may replace the use of such tools with Ruby tools so that the documentation works on Windows too.
* Traveling Ruby currently supports Ruby 2.4.10.
* Traveling Ruby currently supports Ruby 3.1.2.
* Native extensions are not yet supported.

## Building binaries
Expand Down
2 changes: 1 addition & 1 deletion RUBY_VERSIONS.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.10
3.1.2
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20210206
20230504
6 changes: 3 additions & 3 deletions linux/Rakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
IMAGE_VERSION = "1.0"
VERSION = File.read("../VERSION.txt").strip
RUBY_VERSIONS = File.read("../RUBY_VERSIONS.txt").strip.split(/\s+/)
ARCHITECTURES = ["x86_64"]
CONCURRENCY = `./internal/cpucount`.to_i
ARCHITECTURES = ["x86_64",'arm64']
CONCURRENCY = `./internal/cpucount`.to_i + 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why +1?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure! I pulled that change in from this fork

75afdff#diff-fe8ec1b2975d083dd6bc6eaf2fca4dba61a6466d1991a1cbaf3c9dd27b841941L5

I imagine the internal cpu count, is going to be the max, so adding one doesn't make sense, will remove and retest


task :default => :package

Expand Down Expand Up @@ -41,7 +41,7 @@ ARCHITECTURES.each do |arch|

desc "Build the #{arch} Docker image"
task "image:#{arch}" do
sh "docker build --pull" \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no --pull?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh I think that was from testing, I wasn't certain it was using the built image and not pulling the published versioned I had created with the same tag, I added that back in, in the ci branch

I'll add it back in

https://github.com/YOU54F/traveling-ruby/blob/628d1c514f19af7c24e25dcececa3188c03cb188/linux/Rakefile#L44

sh "docker build" \
" -t phusion/traveling-ruby-builder-#{arch}:#{IMAGE_VERSION}" \
" -f image/Dockerfile-#{arch} image"
end
Expand Down
3 changes: 3 additions & 0 deletions linux/image/Dockerfile-arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM --platform=linux/arm64 phusion/holy-build-box:3.0
FooBarWidget marked this conversation as resolved.
Show resolved Hide resolved
ADD . /tr_build
RUN env ARCHITECTURE=arm64 /tr_build/install.sh
2 changes: 1 addition & 1 deletion linux/image/Dockerfile-x86_64
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM phusion/holy-build-box-64:3.0
FROM --platform=linux/amd64 phusion/holy-build-box:3.0
ADD . /tr_build
RUN env ARCHITECTURE=x86_64 /tr_build/install.sh
2 changes: 1 addition & 1 deletion linux/internal/build-ruby
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ if [[ "$DEBUG_SHELL" = before ]]; then
open_debug_shell
fi
if [[ -e /system_shared/gemfiles ]]; then
run /tmp/ruby/bin/gem install bundler -v $BUNDLER_VERSION --no-rdoc --no-ri
run /tmp/ruby/bin/gem install bundler -v $BUNDLER_VERSION --no-document
if [[ "$DEBUG_SHELL" = after ]]; then
install_gems || true
else
Expand Down
5 changes: 3 additions & 2 deletions osx/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ end


RUBY_VERSIONS.each do |ruby_version|
package = "traveling-ruby-#{VERSION}-#{ruby_version}-osx.tar.gz"
gem_dir = "traveling-ruby-gems-#{VERSION}-#{ruby_version}-osx"
arch = `uname -m`.chomp.strip
package = "traveling-ruby-#{VERSION}-#{ruby_version}-osx-#{arch}.tar.gz"
gem_dir = "traveling-ruby-gems-#{VERSION}-#{ruby_version}-osx-#{arch}"

task :package => "package:#{ruby_version}"
task :build => "build:#{ruby_version}"
Expand Down
26 changes: 15 additions & 11 deletions osx/build-ruby
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ OUTPUT_DIR=
RUBY_VERSION=${RUBY_VERSIONS[0]}
WORKDIR=
OWNS_WORKDIR=true
CONCURRENCY=4
CONCURRENCY=$(sysctl -n hw.ncpu)
GEMFILE="$SELFDIR/../shared/gemfiles"
SETUP_SOURCE=true
COMPILE=true
Expand Down Expand Up @@ -230,6 +230,11 @@ fi

header "Preparing Ruby source code..."

# To many warnings, suppress them all (disable in case of troubleshooting)
export CPPFLAGS="-w"
export CXXFLAGS="-w"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This disables optimizations. You should add back at least -O or -O2.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall try both an see what happens :)

export CFLAGS="-w"

export PATH="$RUNTIME_DIR/bin:$PATH"
export LIBRARY_PATH="$RUNTIME_DIR/lib"
export PKG_CONFIG_PATH="$RUNTIME_DIR/lib/pkgconfig:/usr/lib/pkgconfig"
Expand All @@ -255,12 +260,13 @@ echo

if $SETUP_SOURCE; then
header "Configuring..."
# NOTE: the option --disable-install-doc is a conjunction of --disable-install-rdoc and --disable-install-capi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to 3.2.2's ./configure --help, --disable-install-doc is still available.

But I agree that disable-install-rdoc and disable-install-capi can be removed. Just disable-install-doc is enough.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fab thanks

# NOTE: the options --disable-install-doc and --disable-install-rdoc have been removed
# to support the presence of document coders
./configure \
--prefix "$TMPBUILDROOT" \
--disable-install-doc \
--disable-install-rdoc \
--disable-install-capi \
--with-out-ext=tk,sdbm,gdbm,dbm,dl,coverage \
--disable-install-capi \
--with-openssl-dir="$RUNTIME_DIR"
echo
fi
Expand Down Expand Up @@ -325,9 +331,9 @@ if [[ "$GEMFILE" != "" ]]; then

# Install Bundler, either from cache or directly.
if [[ -e "$RUNTIME_DIR/vendor/cache/bundler-$BUNDLER_VERSION.gem" ]]; then
run "$TMPBUILDROOT/bin/gem" install "$RUNTIME_DIR/vendor/cache/bundler-$BUNDLER_VERSION.gem" --no-rdoc --no-ri
run "$TMPBUILDROOT/bin/gem" install "$RUNTIME_DIR/vendor/cache/bundler-$BUNDLER_VERSION.gem" --no-document
else
run "$TMPBUILDROOT/bin/gem" install bundler -v $BUNDLER_VERSION --no-rdoc --no-ri
run "$TMPBUILDROOT/bin/gem" install bundler -v $BUNDLER_VERSION --no-document
run mkdir -p "$RUNTIME_DIR/vendor/cache"
run cp "$TMPBUILDROOT"/lib/ruby/gems/$RUBY_COMPAT_VERSION/cache/bundler-$BUNDLER_VERSION.gem \
"$RUNTIME_DIR/vendor/cache/"
Expand All @@ -344,10 +350,8 @@ if [[ "$GEMFILE" != "" ]]; then
run cp "$GEMFILE.lock" ./
fi
run bundle config --local force_ruby_platform true
# We set -j to 1 because of this bug:
# https://github.com/bundler/bundler/issues/3660
# When it is solved, we can set -j to $CONCURRENCY.
run "$TMPBUILDROOT/bin/bundle" install --system --retry 3 --jobs 1
run "$TMPBUILDROOT/bin/bundle" config set --local system true
run "$TMPBUILDROOT/bin/bundle" install --retry 3 --jobs $CONCURRENCY
run "$TMPBUILDROOT/bin/bundle" package

# Cache gems.
Expand All @@ -372,7 +376,7 @@ run rm -f bin/testrb # Only Ruby 2.1 has it
run rm -rf include
run rm -rf share
run rm -rf lib/{libruby-static.a,pkgconfig}
run rm -rf lib/ruby/$RUBY_COMPAT_VERSION/rdoc/generator/
#run rm -rf lib/ruby/$RUBY_COMPAT_VERSION/rdoc/generator/ # don't remove the documentation generators
run rm -f lib/ruby/gems/$RUBY_COMPAT_VERSION/cache/*
run rm -f lib/ruby/gems/$RUBY_COMPAT_VERSION/extensions/$GEM_PLATFORM/$GEM_EXTENSION_API_VERSION/*/{gem_make.out,mkmf.log}
run rm -rf lib/ruby/gems/$RUBY_COMPAT_VERSION/gems/*/{test,spec,*.md,*.rdoc}
Expand Down
14 changes: 8 additions & 6 deletions osx/internal/check_requirements
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/bin/bash

set -e

XCODEPATH=$(xcode-select -p)

if [[ ! -e "$XCODEPATH/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk" ]]; then
echo "*** ERROR: the macOS 10.14 SDK is required. Please refer to" \
"https://github.com/FooBarWidget/traveling-ruby/blob/main/osx/README.md" \
"for installation instructions." >&2
exit 1
if [[ "$XCODEPATH" == "/Library/Developer/CommandLineTools" ]]; then
XCODEPATH="$XCODEPATH/SDKs/MacOSX.sdk"
elif [[ "$XCODEPATH" == "/Applications/Xcode.app/Contents/Developer" ]]; then
XCODEPATH="$XCODEPATH/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
else
echo "*** ERROR: unknown developer path \"$XCODEPATH\""
exit 1
fi

if [[ -e /usr/local/include ]]; then
Expand Down
20 changes: 20 additions & 0 deletions osx/internal/cmake-3.23.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- CMakeLists.txt.orig 2022-07-05 17:51:38.000000000 +0200
+++ CMakeLists.txt 2022-07-05 17:51:57.000000000 +0200
@@ -101,17 +101,6 @@
endif()
endif()
endif()
-if(NOT CMake_TEST_EXTERNAL_CMAKE)
- # include special compile flags for some compilers
- include(CompileFlags.cmake)
-
- # check for available C++ features
- include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx_features.cmake)
-
- if(NOT CMake_HAVE_CXX_UNIQUE_PTR)
- message(FATAL_ERROR "The C++ compiler does not support C++11 (e.g. std::unique_ptr).")
- endif()
-endif()

# Inform STL library header wrappers whether to use system versions.
configure_file(${CMake_SOURCE_DIR}/Utilities/std/cmSTL.hxx.in
8 changes: 6 additions & 2 deletions osx/internal/reset_environment.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# FIXME: minimal supported deployment target on x86_64 and ARM64?
# NOTE: it looks like this is used only for building PostgreSQL
# export MACOSX_DEPLOYMENT_TARGET=12.1
# FIXME: a full list of deployment targets on ARM64
# FIXME: not used at all?
# export MACOSX_COMPATIBLE_DEPLOYMENT_TARGETS="10.14 10.15 11.0 11.1 11.2 11.3 11.4 11.5 11.6 12.0 12.1"
export PATH="$SELFDIR/internal/bin":/usr/bin:/bin:/usr/sbin:/sbin
export MACOSX_DEPLOYMENT_TARGET=10.14
export MACOSX_COMPATIBLE_DEPLOYMENT_TARGETS="10.14 10.15 11.0 11.1 11.2 11.3 11.4 11.5"
export CC="$SELFDIR/internal/bin/cc"
export CXX="$SELFDIR/internal/bin/c++"
unset DYLD_LIBRARY_PATH
Expand Down
Loading