Skip to content

Commit 6fe20dd

Browse files
Merge branch 'master' into changelog/1.16.0
2 parents 646d79a + f632a0e commit 6fe20dd

37 files changed

+3223
-8710
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ src/openssl/ssl/defaults.cr linguist-generated
2020
src/string/grapheme/properties.cr linguist-generated
2121
# produced by scripts/generate_unicode_data.cr
2222
src/unicode/data.cr linguist-generated
23+
# produced by scripts/generate_glob_specs.cr
24+
spec/std/file/match-fast-glob_spec.cr
2325
# produced by scripts/generate_grapheme_break_specs.cr
2426
spec/std/string/grapheme_break_spec.cr linguist-generated
2527
# produced by spec/generate_wasm32_spec.sh

.github/workflows/aarch64-github.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: AArch64 GitHub CI
2+
3+
on: [push, pull_request]
4+
5+
permissions: {}
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
10+
11+
env:
12+
SPEC_SPLIT_DOTS: 160
13+
14+
jobs:
15+
aarch64-github-cross-compile:
16+
runs-on: ubuntu-24.04
17+
steps:
18+
- name: Download Crystal source
19+
uses: actions/checkout@v4
20+
21+
- name: Install LLVM 20
22+
run: |
23+
sudo apt remove 'llvm-*' 'libllvm*'
24+
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
25+
sudo apt-add-repository -y deb http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main
26+
sudo apt install -y llvm-20-dev
27+
28+
- name: Install Crystal
29+
uses: crystal-lang/install-crystal@v1
30+
with:
31+
crystal: "1.15.1"
32+
33+
- name: Cross-compile Crystal
34+
run: make target=aarch64-linux-gnu release=1
35+
36+
- name: Upload crystal.o
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: aarch64-linux-crystal-o
40+
path: .build/crystal.o
41+
42+
aarch64-github-build:
43+
runs-on: ubuntu-24.04-arm
44+
needs: [aarch64-github-cross-compile]
45+
steps:
46+
- name: Checkout Crystal source
47+
uses: actions/checkout@v4
48+
49+
- name: Install LLVM 20
50+
run: |
51+
sudo apt remove 'llvm-*' 'libllvm*'
52+
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
53+
sudo apt-add-repository -y deb http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main
54+
sudo apt install -y llvm-20-dev
55+
56+
- name: Install dependencies
57+
run: |
58+
sudo apt install -y lld libgc-dev libpcre2-dev
59+
60+
- name: Download crystal.o
61+
uses: actions/download-artifact@v4
62+
with:
63+
name: aarch64-linux-crystal-o
64+
65+
- name: Link Crystal
66+
run: |
67+
mkdir .build
68+
# shellcheck disable=SC2046
69+
cc crystal.o -o .build/crystal \
70+
$(pkg-config bdw-gc libpcre2-8 --libs) \
71+
$(llvm-config-20 --libs --system-libs --ldflags) \
72+
-lm
73+
bin/crystal --version
74+
75+
- name: Run stdlib specs
76+
run: make std_spec
77+
78+
- name: Run compiler specs
79+
run: make compiler_spec
80+
81+
- name: Run interpreter specs
82+
run: make interpreter_spec
83+
84+
- name: Run primitives specs
85+
run: make -o .build/crystal.exe primitives_spec # we know the compiler is fresh; do not rebuild it here

CHANGELOG.0.md

Lines changed: 0 additions & 4208 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 4 additions & 4247 deletions
Large diffs are not rendered by default.

doc/man/crystal-build.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,16 @@ documentation available on the official web site.
5252
*--mcpu* _CPU_::
5353
Specify a specific CPU to generate code for. This will pass a
5454
-mcpu flag to LLVM, and is only intended to be used for cross-
55-
compilation. For a list of available CPUs, invoke "llvm-as <
56-
/dev/null | llc -march=xyz -mcpu=help". Passing --mcpu native
55+
compilation. For a list of available CPUs, pass --mcpu help
56+
when building any Crystal source code. Passing --mcpu native
5757
will pass the host CPU name to tune performance for the host.
5858
*--mattr* _CPU_::
5959
Override or control specific attributes of the target, such as
6060
whether SIMD operations are enabled or not. The default set of
6161
attributes is set by the current CPU. This will pass a -mattr
6262
flag to LLVM, and is only intended to be used for cross-compilation. For a list of available attributes, invoke "llvm-as <
6363
/dev/null | llc -march=xyz -mattr=help".
64-
*--mcmodel* default|kernel|small|medium|large::
64+
*--mcmodel* default|kernel|tiny|small|medium|large::
6565
Specifies a specific code model to generate code for. This will
6666
pass a --code-model flag to LLVM.
6767
*--no-color*::

doc/man/crystal-env.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ Variables:
2222
*CRYSTAL_CACHE_DIR*::
2323
Please see ENVIRONMENT VARIABLES.
2424

25+
*CRYSTAL_EXEC_PATH*::
26+
Please see ENVIRONMENT VARIABLES.
27+
2528
*CRYSTAL_LIBRARY_PATH*::
2629
Please see ENVIRONMENT VARIABLES.
2730

doc/man/crystal.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ subsequent builds. This path is also used to temporarily store executables
131131
when Crystal programs are run with '*crystal* run' rather than '*crystal*
132132
build'.
133133

134+
=== CRYSTAL_EXEC_PATH
135+
Determines the path where *crystal* looks for external sub-commands.
136+
134137
=== CRYSTAL_LIBRARY_PATH
135138
Defines paths where Crystal searches for (binary) libraries. Multiple paths
136139
can be separated by ":". These paths are passed to the linker as `-L`

man/crystal.1

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ documentation available on the official web site.
198198
.RS 4
199199
Specify a specific CPU to generate code for. This will pass a
200200
\-mcpu flag to LLVM, and is only intended to be used for cross\-
201-
compilation. For a list of available CPUs, invoke "llvm\-as <
202-
/dev/null | llc \-march=xyz \-mcpu=help". Passing \-\-mcpu native
201+
compilation. For a list of available CPUs, pass \-\-mcpu help
202+
when building any Crystal source code. Passing \-\-mcpu native
203203
will pass the host CPU name to tune performance for the host.
204204
.RE
205205
.sp
@@ -212,7 +212,7 @@ flag to LLVM, and is only intended to be used for cross\-compilation. For a list
212212
/dev/null | llc \-march=xyz \-mattr=help".
213213
.RE
214214
.sp
215-
\fB\-\-mcmodel\fP default|kernel|small|medium|large
215+
\fB\-\-mcmodel\fP default|kernel|tiny|small|medium|large
216216
.RS 4
217217
Specifies a specific code model to generate code for. This will
218218
pass a \-\-code\-model flag to LLVM.
@@ -415,6 +415,11 @@ Variables:
415415
Please see ENVIRONMENT VARIABLES.
416416
.RE
417417
.sp
418+
\fBCRYSTAL_EXEC_PATH\fP
419+
.RS 4
420+
Please see ENVIRONMENT VARIABLES.
421+
.RE
422+
.sp
418423
\fBCRYSTAL_LIBRARY_PATH\fP
419424
.RS 4
420425
Please see ENVIRONMENT VARIABLES.
@@ -805,6 +810,9 @@ Defines path where Crystal caches partial compilation results for faster
805810
subsequent builds. This path is also used to temporarily store executables
806811
when Crystal programs are run with \*(Aq\fBcrystal\fP run\*(Aq rather than \*(Aq\fBcrystal\fP
807812
build\*(Aq.
813+
.SS "CRYSTAL_EXEC_PATH"
814+
.sp
815+
Determines the path where crystal looks for external sub-commands.
808816
.SS "CRYSTAL_LIBRARY_PATH"
809817
.sp
810818
Defines paths where Crystal searches for (binary) libraries. Multiple paths

samples/fibonacci.cr

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def fibonacci(n : Int32) : Int32
2+
return 0 if n < 0
3+
return n if n <= 1
4+
5+
fibonacci(n - 1) + fibonacci(n - 2)
6+
end
7+
8+
puts "First ten Fibonacci numbers:"
9+
(0..9).each do |n|
10+
puts "fibonacci(#{n}) = #{fibonacci(n)}"
11+
end

scripts/generate_glob_specs.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/env bash
2+
3+
# This tool generates the tests in spec/std/file/match-fast-glob_spec.cr
4+
# from https://github.com/oxc-project/fast-glob/blob/main/tests/test.rs
5+
# converted to Crystal
6+
7+
set -euo pipefail
8+
9+
target=spec/std/file/match-fast-glob_spec.cr
10+
URL="https://raw.githubusercontent.com/oxc-project/fast-glob/refs/heads/main/tests/test.rs"
11+
12+
curl -L "$URL" |
13+
(
14+
echo '
15+
# This file was automatically generated by running:
16+
#
17+
# scripts/generate_glob_specs.cr
18+
#
19+
# DO NOT EDIT
20+
'
21+
22+
echo "
23+
# These tests are autogenerated from $URL
24+
# They are are collection of tests from bash and micromatch
25+
# https://github.com/micromatch/picomatch/blob/master/test/bash.js.
26+
"
27+
28+
echo '
29+
require "spec"
30+
31+
private def assert_file_matches(pattern, path : String, *, file = __FILE__, line = __LINE__)
32+
File.match?(pattern, path).should be_true, file: file, line: line
33+
File.match?(pattern, Path.posix(path)).should be_true, file: file, line: line
34+
File.match?(pattern, Path.posix(path).to_windows(mappings: false)).should be_true, file: file, line: line
35+
end
36+
37+
private def refute_file_matches(pattern, path : String, *, file = __FILE__, line = __LINE__)
38+
File.match?(pattern, path).should be_false, file: file, line: line
39+
File.match?(pattern, Path.posix(path)).should be_false, file: file, line: line
40+
File.match?(pattern, Path.posix(path).to_windows(mappings: false)).should be_false, file: file, line: line
41+
end
42+
'
43+
44+
echo 'describe "File .match? bash tests" do'
45+
46+
sed -E '1,5d' |
47+
sed '/let patterns/,/#\[test\]/d; s/fn not_paired_braces/end\n\nfn not_paired_braces/' | # drop complex patterns implementation
48+
sed '/fn fuzz_tests/,$d' | # drop complex fuzz tests implementation
49+
sed '/^\s*#\[/d' |
50+
sed -E 's/fn (.*)\(\) \{/it "\1" do/' |
51+
sed -E 's/\}$/end/' |
52+
sed -E 's|^\s*//|#|' |
53+
sed -E 's/assert!\(!glob_match\("(.*)", "(.*)"\)\);/refute_file_matches "\1", "\2"/' |
54+
sed -E 's/assert!\(glob_match\("(.*)", "(.*)"\)\);/assert_file_matches "\1", "\2"/' |
55+
# multiline assertions:
56+
sed -E 's/assert!\(glob_match\(/assert_file_matches(/' |
57+
sed -E 's/assert!\(!glob_match\(/refute_file_matches(/' |
58+
sed -E 's/\)\);/)/' |
59+
sed -E 's/let //' |
60+
sed -E 's/it "negation"/pending "negation"/' | # File.match? currently does not support negated patterns
61+
sed -E '/it "generic_input"/,/end$/d' # Generic input tests are specific to Rust types
62+
63+
echo 'end'
64+
) > "$target"
65+
66+
crystal tool format "$target"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{% skip_file unless flag?(:execution_context) %}
2+
require "spec"
3+
4+
describe Fiber::ExecutionContext::MultiThreaded do
5+
it ".new" do
6+
mt = Fiber::ExecutionContext::MultiThreaded.new("test", maximum: 2)
7+
mt.size.should eq(0)
8+
mt.capacity.should eq(2)
9+
10+
expect_raises(ArgumentError, "needs at least one thread") do
11+
Fiber::ExecutionContext::MultiThreaded.new("test", maximum: -1)
12+
end
13+
14+
expect_raises(ArgumentError, "needs at least one thread") do
15+
Fiber::ExecutionContext::MultiThreaded.new("test", maximum: 0)
16+
end
17+
18+
mt = Fiber::ExecutionContext::MultiThreaded.new("test", size: 0..2)
19+
mt.size.should eq(0)
20+
mt.capacity.should eq(2)
21+
22+
mt = Fiber::ExecutionContext::MultiThreaded.new("test", size: ..4)
23+
mt.size.should eq(0)
24+
mt.capacity.should eq(4)
25+
26+
mt = Fiber::ExecutionContext::MultiThreaded.new("test", size: 1..5)
27+
mt.size.should eq(1)
28+
mt.capacity.should eq(5)
29+
30+
mt = Fiber::ExecutionContext::MultiThreaded.new("test", size: 1...5)
31+
mt.size.should eq(1)
32+
mt.capacity.should eq(4)
33+
34+
expect_raises(ArgumentError, "needs at least one thread") do
35+
Fiber::ExecutionContext::MultiThreaded.new("test", size: 0...1)
36+
end
37+
38+
expect_raises(ArgumentError, "invalid range") do
39+
Fiber::ExecutionContext::MultiThreaded.new("test", size: 5..1)
40+
end
41+
end
42+
end

0 commit comments

Comments
 (0)