Crystal 1.12.0 is released!
We are announcing a new Crystal release with several new features and bug fixes.
Pre-built packages are available on GitHub Releases and our official distribution channels. See crystal-lang.org/install for instructions.
Stats
This release includes 142 changes since 1.11.2 by 14 contributors. We thank all the contributors for all the effort put into improving the language! ❤️
Changes
Below we list the most remarkable changes in the language, compiler and stdlib. For more details, visit the full changelog.
Breaking
Respect alignments above alignof(Void*)
inside union values. This is an ABI breaking change. Crystal makes no guarantees about ABI stability. Most users won’t be affected by this. (#14279)
Thanks @HertzDevil
Process termination handler
Process.on_terminate
replaces Process.on_interrupt
as a more potent and portable API for responding to termination requests (#13694).
All current uses of on_interrupt
can be replaced by on_terminate
with the effect of responding to more termination triggers.
Method | Unix | Windows |
---|---|---|
on_terminate |
SIGINT , SIGHUP and SIGTERM |
Ctrl + C, Ctrl + Break, terminal close, windows logoff and shutdown signals sent to a console application. |
on_interrupt |
SIGINT |
Ctrl + C and Ctrl + Break signals sent to a console application |
This removes the need for adding platform-specific handlers in your code base to handle terminations that were previously not covered by on_interrupt
.
In addition, on_terminate
also passes an instance of Process::ExitReason
to the handler block, allowing it to react differently to specific termination events.
Process.on_terminate do |reason|
case reason
when .interrupted?
puts "terminating gracefully"
when .terminal_disconnected?
puts "reloading configuration"
else
puts "terminating forcefully"
Process.exit(1)
end
end
puts "Waiting for termination"
sleep
Thanks @stakach
Concurrency
There are a couple minor improvements for concurrency which are foreshadowing more significant changes for the upcoming multi-threaded runtime enhancement.
- Backtraces for unhandled exceptions in
spawn
are printed at once in multi-threading mode to avoid unreadable interleaving lines (#14220). - When opening a
File
, it’s now possible to disable blocking mode which is useful for pipes and character devices (#14255). - Some issues with atomics and locks got fixed and
Atomic
operations now receive an optional parameter to define the strength of ordering guarantees asAtomic::Ordering
. New macroAtomic.fence
adds explicit memory barriers (#14293). Thread
got aname
property to identify the thread. It can be set at initialization or for the current thread withThread.name=
(#14257).- Init schedulers before we spawn fibers (#14339).
- Use per-scheduler stack pools, helping recycling stacks (#14100).
Thanks @ysbaddaden
- Add memory barrier to
Mutex#unlock
on aarch64 (#14272).
Thanks @jgaskins
Libraries
We enabled support for OpenSSL 3.2 by fixing a bug in error handling for the OpenSSL 3.x series (#14219).
Thanks @ysbaddaden
Our own LLVM extension library libllvm_ext
is no longer required when linking LLVM >= 18 (#14357) because all APIs are now directly exposed in libllvm
directly. The Makefile automatically skips building libllvm_ext.o
on LLVM 18 and above.
Thanks @HertzDevil
Numeric
- Add
BigRational#%
,#tdiv
,#remainder
(#14306).
Thanks @HertzDevil
Operators with =
suffix
Operators ending with =
can now receive multiple parameters and blocks (#14159) and they are properly forwarded by the delegate
macro (#14282).
The operator #[]=
can be called with with a block using method syntax: x.[]=() { }
(#14161)
Thanks @HertzDevil
Windows progress
- Handle invalid parameter error in MSVC calls to prevent an immediate process exit (#14313)
- Install system dependencies in the Windows GUI installer (#14328)
- Automatically detect MSVC tools on Windows interpreter (#14391)
- Support
@[Link]
’s DLL search order in the interpreter on Windows (#14146) - Reserve stack space on non-main threads for crash recovery on Windows (#14187).
FileUtils.mv
works across filesystems on Windows (#14320).
Thanks @HertzDevil
Misc
-
The time zone identifier
Etc/UTC
was added as an implicit alias toUTC
and works without requiring a copy of the time zone database (#14185)Thanks @femto
-
Crystal::System::FileDescriptor::Handle
is a generic alias to the platform-specific type representing a file descriptor (#14390)Thanks @straight-shoota
-
Hash#update
(#14417) andHash#put_if_absent
(#14427) no longer put duplicate keys if the block inserts the key.Thanks @HertzDevil
-
New method
Signal#trap_handler?
returns any existing handler for the signal (#14126)Thanks @stakach
-
Added macro methods to several AST node types,
lib
& co (#14218),Primitive
(#14263),TypeOf
(#14262),Alias
(#14261),Asm
andAsmOperand
(#14268).Thanks @HertzDevil
Compiler
-
Add
CRYSTAL_CONFIG_CC
compiler config variable. This bakes in a reference to a specific compiler which is useful for 3rd party package managers such as Homebrew so that the compiler picks up the appropriate library paths (#14318).Thanks @straight-shoota
-
Support for
NO_COLOR
(#14260),--static
on Windows (#14292),--single-module
and--threads
foreval
andspec
(#14341)Thanks @HertzDevil
-
Preliminary support for Solaris/illumos has landed in the compiler and stdlib.
Thanks @HertzDevil
-
New CLI option
--frame-pointers
to control preservation of frame pointers (#13860)Thanks @refi64
-
short_reference
for top-level macros was changed to::foo
instead oftop-level foo
(#14203)Thanks @femto
Compiler dependencies
The compiler’s own dependencies are now managed with shards
(#14365). The source code in lib/
stays vendored in the repository, so shards
is not required in order to build the compiler. It’s only used for updating the dependencies in a much easier way than than with the previous approach based on git subtree
.
Thanks @straight-shoota
crystal tool flags
This release brings a new compiler tool: crystal tool flags
(#14234).
It prints all values passed to calls to macro flag?
so you can extract all compile time flags that a program recognizes.
Thanks @straight-shoota
Formatter enhancements
Improved the formatter for ProcLiteral
s (#14209), asm
with comments (#14278), white space in a.[b]
syntax (#14346), calls without parentheses followed by doc comment (#14354), whitespace in foo ()
(#14439).
Thanks @HertzDevil, @straight-shoota
Shards 0.18.0
The bundled shards release was updated to 0.18.0.
This new shards release brings a couple of enhancements for Windows support, particularly support for more cache directories (#612), detection of symlink creation capability (#617) and a lot more improvements on internal tooling. Starting with this release, shards’ output by default is only colored if stdout is a TTY instead of always (#620).
Thanks @HertzDevil, @straight-shoota
Experimental: ReferenceStorage
Originally introduced in 1.11.0, the ReferenceStorage
type was removed again in 1.11.1 due to compatibility issues with older versions of the standard library (#14207).
We now have an improved implementation that shows no compatibility issues.
ReferenceStorage
represents a static buffer for a reference allocation.
These APIs are still experimental and might be subject to change. We expect more features in this direction in future releases. Join the discussion about custom reference allocation at #13481.
Thanks @HertzDevil
Deprecations
- Setter methods for timeouts with
Number
parameter (#14372). - Compile time flag
openbsd6.2
got removed (#14233). - The spec runner’s state moved into
Spec::CLI
. This is only relevant for code which monkey-patches into the spec library (#14170).
We have been able to do all of this thanks to the continued support of 84codes and every other sponsor. To maintain and increase the development pace, donations and sponsorships are essential. OpenCollective is available for that.
Reach out to crystal@manas.tech if you’d like to become a direct sponsor or find other ways to support Crystal. We thank you in advance!
Contribute