Skip to content

Commit

Permalink
Merge branch 'master' into refactor/linux-getrandom
Browse files Browse the repository at this point in the history
  • Loading branch information
ysbaddaden authored Oct 8, 2024
2 parents 6744811 + dddc0dc commit 7a3e219
Show file tree
Hide file tree
Showing 31 changed files with 209 additions and 211 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/aarch64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
src/llvm/ext/llvm_ext.o
aarch64-musl-test-stdlib:
needs: aarch64-musl-build
runs-on: [runs-on, runner=2cpu-linux-arm64, "family=m7g", ram=8, "run-id=${{ github.run_id }}"]
runs-on: [runs-on, runner=4cpu-linux-arm64, "family=m7g", ram=16, "run-id=${{ github.run_id }}"]
if: github.repository == 'crystal-lang/crystal'
steps:
- name: Download Crystal source
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
src/llvm/ext/llvm_ext.o
aarch64-gnu-test-stdlib:
needs: aarch64-gnu-build
runs-on: [runs-on, runner=2cpu-linux-arm64, "family=m7g", ram=8, "run-id=${{ github.run_id }}"]
runs-on: [runs-on, runner=4cpu-linux-arm64, "family=m7g", ram=16, "run-id=${{ github.run_id }}"]
if: github.repository == 'crystal-lang/crystal'
steps:
- name: Download Crystal source
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/llvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@ jobs:
matrix:
include:
- llvm_version: "13.0.0"
llvm_ubuntu_version: "20.04"
llvm_filename: "clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz"
- llvm_version: "14.0.0"
llvm_ubuntu_version: "18.04"
llvm_filename: "clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz"
- llvm_version: "15.0.6"
llvm_ubuntu_version: "18.04"
llvm_filename: "clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04.tar.xz"
- llvm_version: "16.0.3"
llvm_ubuntu_version: "22.04"
llvm_filename: "clang+llvm-16.0.3-x86_64-linux-gnu-ubuntu-22.04.tar.xz"
- llvm_version: "17.0.6"
llvm_ubuntu_version: "22.04"
llvm_filename: "clang+llvm-17.0.6-x86_64-linux-gnu-ubuntu-22.04.tar.xz"
- llvm_version: "18.1.4"
llvm_ubuntu_version: "18.04"
llvm_filename: "clang+llvm-18.1.4-x86_64-linux-gnu-ubuntu-18.04.tar.xz"
- llvm_version: "19.1.0"
llvm_filename: "LLVM-19.1.0-Linux-X64.tar.xz"
name: "LLVM ${{ matrix.llvm_version }}"
steps:
- name: Checkout Crystal source
Expand All @@ -44,7 +46,7 @@ jobs:
- name: Install LLVM ${{ matrix.llvm_version }}
run: |
mkdir -p llvm
curl -L "https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ matrix.llvm_version }}/clang+llvm-${{ matrix.llvm_version }}-x86_64-linux-gnu-ubuntu-${{ matrix.llvm_ubuntu_version }}.tar.xz" > llvm.tar.xz
curl -L "https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ matrix.llvm_version }}/${{ matrix.llvm_filename }}" > llvm.tar.xz
tar x --xz -C llvm --strip-components=1 -f llvm.tar.xz
if: steps.cache-llvm.outputs.cache-hit != 'true'

Expand Down
2 changes: 0 additions & 2 deletions spec/compiler/codegen/debug_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ describe "Code gen: debug" do

it "has debug info in closure inside if (#5593)" do
codegen(%(
require "prelude"
def foo
if true && true
yield 1
Expand Down
136 changes: 0 additions & 136 deletions spec/compiler/crystal/tools/doc/type_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -212,140 +212,4 @@ describe Doc::Type do
type.macros.map(&.name).should eq ["+", "~", "foo"]
end
end

describe "#subclasses" do
it "only include types with docs" do
program = semantic(<<-CRYSTAL, wants_doc: true).program
class Foo
end
class Bar < Foo
end
# :nodoc:
class Baz < Foo
end
module Mod1
class Bar < ::Foo
end
end
# :nodoc:
module Mod2
class Baz < ::Foo
end
end
CRYSTAL

generator = Doc::Generator.new program, [""]
type = generator.type(program.types["Foo"])
type.subclasses.map(&.full_name).should eq ["Bar", "Mod1::Bar"]
end
end

describe "#ancestors" do
it "only include types with docs" do
program = semantic(<<-CRYSTAL, wants_doc: true).program
# :nodoc:
module Mod3
class Baz
end
end
class Mod2::Baz < Mod3::Baz
end
module Mod1
# :nodoc:
class Baz < Mod2::Baz
end
end
class Baz < Mod1::Baz
end
class Foo < Baz
end
CRYSTAL

generator = Doc::Generator.new program, [""]
type = generator.type(program.types["Foo"])
type.ancestors.map(&.full_name).should eq ["Baz", "Mod2::Baz"]
end
end

describe "#included_modules" do
it "only include types with docs" do
program = semantic(<<-CRYSTAL, wants_doc: true).program
# :nodoc:
module Mod3
module Baz
end
end
module Mod2
# :nodoc:
module Baz
end
end
module Mod1
module Baz
end
end
module Baz
end
class Foo
include Baz
include Mod1::Baz
include Mod2::Baz
include Mod3::Baz
end
CRYSTAL

generator = Doc::Generator.new program, [""]
type = generator.type(program.types["Foo"])
type.included_modules.map(&.full_name).should eq ["Baz", "Mod1::Baz"]
end
end

describe "#included_modules" do
it "only include types with docs" do
program = semantic(<<-CRYSTAL, wants_doc: true).program
# :nodoc:
module Mod3
module Baz
end
end
module Mod2
# :nodoc:
module Baz
end
end
module Mod1
module Baz
end
end
module Baz
end
class Foo
extend Baz
extend Mod1::Baz
extend Mod2::Baz
extend Mod3::Baz
end
CRYSTAL

generator = Doc::Generator.new program, [""]
type = generator.type(program.types["Foo"])
type.extended_modules.map(&.full_name).should eq ["Baz", "Mod1::Baz"]
end
end
end
8 changes: 8 additions & 0 deletions spec/compiler/crystal/tools/unreachable_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ describe "unreachable" do
CRYSTAL
end

it "handles circular hierarchy references (#14034)" do
assert_unreachable <<-CRYSTAL
class Foo
alias Bar = Foo
end
CRYSTAL
end

it "finds initializer" do
assert_unreachable <<-CRYSTAL
class Foo
Expand Down
7 changes: 7 additions & 0 deletions spec/compiler/interpreter/unions_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ describe Crystal::Repl::Interpreter do
CRYSTAL
end

it "returns large union type (#15041)" do
interpret(<<-CRYSTAL).should eq(4_i64)
a = {3_i64, 4_i64} || nil
a.is_a?(Tuple) ? a[1] : 5_i64
CRYSTAL
end

it "put and remove from union in local var" do
interpret(<<-CRYSTAL).should eq(3)
a = 1 == 1 ? 2 : true
Expand Down
16 changes: 16 additions & 0 deletions spec/compiler/semantic/alias_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,22 @@ describe "Semantic: alias" do
Bar.bar
)) { int32 }
end

it "reopens #{type} through alias within itself" do
assert_type <<-CRYSTAL { int32 }
#{type} Foo
alias Bar = Foo
#{type} Bar
def self.bar
1
end
end
end
Foo.bar
CRYSTAL
end
end

%w(class struct).each do |type|
Expand Down
23 changes: 9 additions & 14 deletions spec/std/kernel_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -254,27 +254,22 @@ describe "hardware exception" do
error.should_not contain("Stack overflow")
end

{% if flag?(:musl) %}
# FIXME: Pending as mitigation for https://github.com/crystal-lang/crystal/issues/7482
pending "detects stack overflow on the main stack"
{% else %}
it "detects stack overflow on the main stack", tags: %w[slow] do
# This spec can take some time under FreeBSD where
# the default stack size is 0.5G. Setting a
# smaller stack size with `ulimit -s 8192`
# will address this.
status, _, error = compile_and_run_source <<-'CRYSTAL'
it "detects stack overflow on the main stack", tags: %w[slow] do
# This spec can take some time under FreeBSD where
# the default stack size is 0.5G. Setting a
# smaller stack size with `ulimit -s 8192`
# will address this.
status, _, error = compile_and_run_source <<-'CRYSTAL'
def foo
y = StaticArray(Int8, 512).new(0)
foo
end
foo
CRYSTAL

status.success?.should be_false
error.should contain("Stack overflow")
end
{% end %}
status.success?.should be_false
error.should contain("Stack overflow")
end

it "detects stack overflow on a fiber stack", tags: %w[slow] do
status, _, error = compile_and_run_source <<-'CRYSTAL'
Expand Down
8 changes: 0 additions & 8 deletions spec/std/thread/condition_variable_spec.cr
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
{% if flag?(:musl) %}
# FIXME: These thread specs occasionally fail on musl/alpine based ci, so
# they're disabled for now to reduce noise.
# See https://github.com/crystal-lang/crystal/issues/8738
pending Thread::ConditionVariable
{% skip_file %}
{% end %}

require "../spec_helper"

# interpreter doesn't support threads yet (#14287)
Expand Down
8 changes: 0 additions & 8 deletions spec/std/thread/mutex_spec.cr
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
{% if flag?(:musl) %}
# FIXME: These thread specs occasionally fail on musl/alpine based ci, so
# they're disabled for now to reduce noise.
# See https://github.com/crystal-lang/crystal/issues/8738
pending Thread::Mutex
{% skip_file %}
{% end %}

require "../spec_helper"

# interpreter doesn't support threads yet (#14287)
Expand Down
8 changes: 0 additions & 8 deletions spec/std/thread_spec.cr
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
require "./spec_helper"

{% if flag?(:musl) %}
# FIXME: These thread specs occasionally fail on musl/alpine based ci, so
# they're disabled for now to reduce noise.
# See https://github.com/crystal-lang/crystal/issues/8738
pending Thread
{% skip_file %}
{% end %}

# interpreter doesn't support threads yet (#14287)
pending_interpreted describe: Thread do
it "allows passing an argumentless fun to execute" do
Expand Down
16 changes: 16 additions & 0 deletions src/compiler/crystal/codegen/debug.cr
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,16 @@ module Crystal
old_debug_location = @current_debug_location
set_current_debug_location location
if builder.current_debug_location != llvm_nil && (ptr = alloca)
# FIXME: When debug records are used instead of debug intrinsics, it
# seems inserting them into an empty BasicBlock will instead place them
# in a totally different (next?) function where the variable doesn't
# exist, leading to a "function-local metadata used in wrong function"
# validation error. This might happen when e.g. all variables inside a
# block are closured. Ideally every debug record should immediately
# follow the variable it declares.
{% unless LibLLVM::IS_LT_190 %}
call(do_nothing_fun) if block.instructions.empty?
{% end %}
di_builder.insert_declare_at_end(ptr, var, expr, builder.current_debug_location_metadata, block)
set_current_debug_location old_debug_location
true
Expand All @@ -376,6 +386,12 @@ module Crystal
end
end

private def do_nothing_fun
fetch_typed_fun(@llvm_mod, "llvm.donothing") do
LLVM::Type.function([] of LLVM::Type, @llvm_context.void)
end
end

# Emit debug info for toplevel variables. Used for the main module and all
# required files.
def emit_vars_debug_info(vars)
Expand Down
8 changes: 5 additions & 3 deletions src/compiler/crystal/interpreter/instructions.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ require "./repl"
code: begin
tmp_stack = stack
stack_grow_by(union_size - from_size)
(tmp_stack - from_size).copy_to(tmp_stack - from_size + type_id_bytesize, from_size)
(tmp_stack - from_size).move_to(tmp_stack - from_size + type_id_bytesize, from_size)
(tmp_stack - from_size).as(Int64*).value = type_id.to_i64!
end,
disassemble: {
Expand All @@ -1319,6 +1319,8 @@ require "./repl"
put_reference_type_in_union: {
operands: [union_size : Int32],
code: begin
# `copy_to` here is valid only when `from_size <= type_id_bytesize`,
# which is always true
from_size = sizeof(Pointer(UInt8))
reference = (stack - from_size).as(UInt8**).value
type_id =
Expand Down Expand Up @@ -1462,7 +1464,7 @@ require "./repl"
tuple_indexer_known_index: {
operands: [tuple_size : Int32, offset : Int32, value_size : Int32],
code: begin
(stack - tuple_size).copy_from(stack - tuple_size + offset, value_size)
(stack - tuple_size).move_from(stack - tuple_size + offset, value_size)
aligned_value_size = align(value_size)
stack_shrink_by(tuple_size - value_size)
stack_grow_by(aligned_value_size - value_size)
Expand All @@ -1474,7 +1476,7 @@ require "./repl"
},
tuple_copy_element: {
operands: [tuple_size : Int32, old_offset : Int32, new_offset : Int32, element_size : Int32],
code: (stack - tuple_size + new_offset).copy_from(stack - tuple_size + old_offset, element_size),
code: (stack - tuple_size + new_offset).move_from(stack - tuple_size + old_offset, element_size),
},
# >>> Tuples (3)

Expand Down
Loading

0 comments on commit 7a3e219

Please sign in to comment.