From 97806dcc8c1a14022cf2e67edaf79e84ebc06c81 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 1 Sep 2023 12:43:13 +0000 Subject: [PATCH 1/4] [GR-43819] Update GRAAL_SDK dependency to POLYGLOT. PullRequest: truffleruby/3982 (cherry picked from commit 7bfab8511d8b1c00b5032d1f93638c58ac8899f6) --- mx.truffleruby/suite.py | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/mx.truffleruby/suite.py b/mx.truffleruby/suite.py index 15251cf0cdcc..713b3b404fae 100644 --- a/mx.truffleruby/suite.py +++ b/mx.truffleruby/suite.py @@ -164,7 +164,7 @@ "requires": ["java.management"], "dependencies": [ "truffleruby:TRUFFLERUBY-ANNOTATIONS", - "sdk:GRAAL_SDK", + "sdk:POLYGLOT", ], "annotationProcessors": [ "TRUFFLERUBY-PROCESSOR", @@ -207,20 +207,6 @@ "license": ["EPL-2.0"], }, - "org.truffleruby.services": { - "dir": "src/services", - "sourceDirs": ["java"], - "requires": ["java.scripting"], - "dependencies": [ - "sdk:GRAAL_SDK", - ], - "jacoco": "include", - "javaCompliance": "17+", - "checkstyle": "org.truffleruby", - "workingSets": "TruffleRuby", - "license": ["EPL-2.0"], - }, - "org.truffleruby.rubysignal": { "dir": "src/main/c/rubysignal", "native": "shared_lib", @@ -325,7 +311,7 @@ "dependencies": [ "truffleruby:TRUFFLERUBY-ANNOTATIONS", "truffleruby:TRUFFLERUBY-SHARED", - "sdk:GRAAL_SDK", + "sdk:POLYGLOT", "sdk:LAUNCHER_COMMON", ], "jacoco": "include", @@ -468,7 +454,7 @@ ], "distDependencies": [ "truffleruby:TRUFFLERUBY-ANNOTATIONS", - "sdk:GRAAL_SDK", + "sdk:POLYGLOT", ], "description": "TruffleRuby Shared constants and predicates", "license": ["EPL-2.0"], @@ -578,7 +564,7 @@ "distDependencies": [ "truffleruby:TRUFFLERUBY-ANNOTATIONS", "truffleruby:TRUFFLERUBY-SHARED", - "sdk:GRAAL_SDK", + "sdk:POLYGLOT", "sdk:LAUNCHER_COMMON", ], "description": "TruffleRuby Launcher", From 4dd0388daf8cee7ba1efc4d74bc98bc5b7a385f3 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Mon, 4 Sep 2023 12:41:14 +0000 Subject: [PATCH 2/4] [GR-23507] Tag specs using execve() and switch to --vm.Xlog:os+thread=off,gc+task=off PullRequest: truffleruby/3988 (cherry picked from commit 222cc345c9b793395c831a0be8487f60b6ea421a) --- spec/mspec/tool/tag_from_output.rb | 4 +- spec/ruby/command_line/dash_a_spec.rb | 4 +- spec/ruby/command_line/dash_l_spec.rb | 8 ++-- spec/ruby/command_line/dash_n_spec.rb | 8 ++-- spec/ruby/command_line/dash_p_spec.rb | 4 +- spec/ruby/command_line/dash_upper_f_spec.rb | 2 +- spec/ruby/command_line/rubyopt_spec.rb | 14 +++---- spec/ruby/core/argf/readpartial_spec.rb | 2 +- spec/ruby/core/file/flock_spec.rb | 4 +- spec/ruby/core/kernel/exec_spec.rb | 4 +- spec/ruby/core/process/exec_spec.rb | 42 ++++++++++----------- spec/ruby/language/alias_spec.rb | 2 +- spec/tags/core/kernel/exec_tags.txt | 2 + spec/tags/core/process/exec_tags.txt | 25 ++++++++++++ spec/tags/truffle/launcher_tags.txt | 4 ++ spec/truffle/launcher_spec.rb | 2 +- spec/truffleruby.mspec | 4 ++ tool/jt.rb | 7 ++-- 18 files changed, 89 insertions(+), 53 deletions(-) diff --git a/spec/mspec/tool/tag_from_output.rb b/spec/mspec/tool/tag_from_output.rb index a6e60945cdf8..025a040f9b5f 100755 --- a/spec/mspec/tool/tag_from_output.rb +++ b/spec/mspec/tool/tag_from_output.rb @@ -3,6 +3,8 @@ # Adds tags based on error and failures output (e.g., from a CI log), # without running any spec code. +tag = ENV["TAG"] || "fails" + tags_dir = %w[ spec/tags spec/tags/ruby @@ -54,7 +56,7 @@ dir = File.dirname(tags_file) Dir.mkdir(dir) unless Dir.exist?(dir) - tag_line = "fails:#{description}" + tag_line = "#{tag}:#{description}" lines = File.exist?(tags_file) ? File.readlines(tags_file, chomp: true) : [] unless lines.include?(tag_line) puts tags_file diff --git a/spec/ruby/command_line/dash_a_spec.rb b/spec/ruby/command_line/dash_a_spec.rb index 9ea135dc76f3..43d923ce1644 100644 --- a/spec/ruby/command_line/dash_a_spec.rb +++ b/spec/ruby/command_line/dash_a_spec.rb @@ -6,13 +6,13 @@ end it "runs the code in loop conditional on Kernel.gets()" do - ruby_exe("puts $F.last", options: "-n -a", escape: true, + ruby_exe("puts $F.last", options: "-n -a", args: " < #{@names}").should == "jones\nfield\ngrey\n" end it "sets $-a" do - ruby_exe("puts $-a", options: "-n -a", escape: true, + ruby_exe("puts $-a", options: "-n -a", args: " < #{@names}").should == "true\ntrue\ntrue\n" end diff --git a/spec/ruby/command_line/dash_l_spec.rb b/spec/ruby/command_line/dash_l_spec.rb index 5c1d3cf4cd9d..44a98445f379 100644 --- a/spec/ruby/command_line/dash_l_spec.rb +++ b/spec/ruby/command_line/dash_l_spec.rb @@ -6,25 +6,25 @@ end it "chomps lines with default separator" do - ruby_exe('puts $_.end_with?("\n")', options: "-n -l", escape: true, + ruby_exe('puts $_.end_with?("\n")', options: "-n -l", args: " < #{@names}").should == "false\nfalse\nfalse\n" end it "chomps last line based on $/" do - ruby_exe('BEGIN { $/ = "ones\n" }; puts $_', options: "-W0 -n -l", escape: true, + ruby_exe('BEGIN { $/ = "ones\n" }; puts $_', options: "-W0 -n -l", args: " < #{@names}").should == "alice j\nbob field\njames grey\n" end it "sets $\\ to the value of $/" do - ruby_exe("puts $\\ == $/", options: "-W0 -n -l", escape: true, + ruby_exe("puts $\\ == $/", options: "-W0 -n -l", args: " < #{@names}").should == "true\ntrue\ntrue\n" end it "sets $-l" do - ruby_exe("puts $-l", options: "-n -l", escape: true, + ruby_exe("puts $-l", options: "-n -l", args: " < #{@names}").should == "true\ntrue\ntrue\n" end diff --git a/spec/ruby/command_line/dash_n_spec.rb b/spec/ruby/command_line/dash_n_spec.rb index 9d331d6065db..1dd9379259b4 100644 --- a/spec/ruby/command_line/dash_n_spec.rb +++ b/spec/ruby/command_line/dash_n_spec.rb @@ -6,19 +6,19 @@ end it "runs the code in loop conditional on Kernel.gets()" do - ruby_exe("puts $_", options: "-n", escape: true, + ruby_exe("puts $_", options: "-n", args: " < #{@names}").should == "alice\nbob\njames\n" end it "only evaluates BEGIN blocks once" do - ruby_exe("BEGIN { puts \"hi\" }; puts $_", options: "-n", escape: true, + ruby_exe("BEGIN { puts \"hi\" }; puts $_", options: "-n", args: " < #{@names}").should == "hi\nalice\nbob\njames\n" end it "only evaluates END blocks once" do - ruby_exe("puts $_; END {puts \"bye\"}", options: "-n", escape: true, + ruby_exe("puts $_; END {puts \"bye\"}", options: "-n", args: " < #{@names}").should == "alice\nbob\njames\nbye\n" end @@ -29,7 +29,7 @@ $total += 1 END { puts $total } script - ruby_exe(script, options: "-n", escape: true, + ruby_exe(script, options: "-n", args: " < #{@names}").should == "3\n" end diff --git a/spec/ruby/command_line/dash_p_spec.rb b/spec/ruby/command_line/dash_p_spec.rb index 39827c3868cc..967e3796de22 100644 --- a/spec/ruby/command_line/dash_p_spec.rb +++ b/spec/ruby/command_line/dash_p_spec.rb @@ -6,13 +6,13 @@ end it "runs the code in loop conditional on Kernel.gets() and prints $_" do - ruby_exe("$_ = $_.upcase", options: "-p", escape: true, + ruby_exe("$_ = $_.upcase", options: "-p", args: " < #{@names}").should == "ALICE\nBOB\nJAMES\n" end it "sets $-p" do - ruby_exe("$_ = $-p", options: "-p", escape: true, + ruby_exe("$_ = $-p", options: "-p", args: " < #{@names}").should == "truetruetrue" end diff --git a/spec/ruby/command_line/dash_upper_f_spec.rb b/spec/ruby/command_line/dash_upper_f_spec.rb index 967acc2ece1f..5c10a7140d16 100644 --- a/spec/ruby/command_line/dash_upper_f_spec.rb +++ b/spec/ruby/command_line/dash_upper_f_spec.rb @@ -6,7 +6,7 @@ end it "specifies the field separator pattern for -a" do - ruby_exe("puts $F[0]", options: "-naF:", escape: true, + ruby_exe("puts $F[0]", options: "-naF:", args: " < #{@passwd}").should == "nobody\nroot\ndaemon\n" end diff --git a/spec/ruby/command_line/rubyopt_spec.rb b/spec/ruby/command_line/rubyopt_spec.rb index bbea4d557d16..734db8d519e2 100644 --- a/spec/ruby/command_line/rubyopt_spec.rb +++ b/spec/ruby/command_line/rubyopt_spec.rb @@ -11,14 +11,14 @@ it "adds the -I path to $LOAD_PATH" do ENV["RUBYOPT"] = "-Ioptrubyspecincl" - result = ruby_exe("puts $LOAD_PATH.grep(/byspecin/)", escape: true) + result = ruby_exe("puts $LOAD_PATH.grep(/byspecin/)") result.chomp[-15..-1].should == "optrubyspecincl" end it "sets $DEBUG to true for '-d'" do ENV["RUBYOPT"] = '-d' command = %[puts "value of $DEBUG is \#{$DEBUG}"] - result = ruby_exe(command, escape: true, args: "2>&1") + result = ruby_exe(command, args: "2>&1") result.should =~ /value of \$DEBUG is true/ end @@ -36,27 +36,27 @@ it "sets $VERBOSE to true for '-w'" do ENV["RUBYOPT"] = '-w' - ruby_exe("p $VERBOSE", escape: true).chomp.should == "true" + ruby_exe("p $VERBOSE").chomp.should == "true" end it "sets $VERBOSE to true for '-W'" do ENV["RUBYOPT"] = '-W' - ruby_exe("p $VERBOSE", escape: true).chomp.should == "true" + ruby_exe("p $VERBOSE").chomp.should == "true" end it "sets $VERBOSE to nil for '-W0'" do ENV["RUBYOPT"] = '-W0' - ruby_exe("p $VERBOSE", escape: true).chomp.should == "nil" + ruby_exe("p $VERBOSE").chomp.should == "nil" end it "sets $VERBOSE to false for '-W1'" do ENV["RUBYOPT"] = '-W1' - ruby_exe("p $VERBOSE", escape: true).chomp.should == "false" + ruby_exe("p $VERBOSE").chomp.should == "false" end it "sets $VERBOSE to true for '-W2'" do ENV["RUBYOPT"] = '-W2' - ruby_exe("p $VERBOSE", escape: true).chomp.should == "true" + ruby_exe("p $VERBOSE").chomp.should == "true" end it "suppresses deprecation warnings for '-W:no-deprecated'" do diff --git a/spec/ruby/core/argf/readpartial_spec.rb b/spec/ruby/core/argf/readpartial_spec.rb index 5e284b34233c..bbc8831131db 100644 --- a/spec/ruby/core/argf/readpartial_spec.rb +++ b/spec/ruby/core/argf/readpartial_spec.rb @@ -69,7 +69,7 @@ print ARGF.readpartial(#{@stdin.size}) ARGF.readpartial(1) rescue print $!.class STR - stdin = ruby_exe(ruby_str, args: "< #{@stdin_name}", escape: true) + stdin = ruby_exe(ruby_str, args: "< #{@stdin_name}") stdin.should == @stdin + "EOFError" end end diff --git a/spec/ruby/core/file/flock_spec.rb b/spec/ruby/core/file/flock_spec.rb index 751e99d994ef..070d830bc470 100644 --- a/spec/ruby/core/file/flock_spec.rb +++ b/spec/ruby/core/file/flock_spec.rb @@ -30,7 +30,7 @@ it "returns false if trying to lock an exclusively locked file" do @file.flock File::LOCK_EX - ruby_exe(<<-END_OF_CODE, escape: true).should == "false" + ruby_exe(<<-END_OF_CODE).should == "false" File.open('#{@name}', "w") do |f2| print f2.flock(File::LOCK_EX | File::LOCK_NB).to_s end @@ -40,7 +40,7 @@ it "blocks if trying to lock an exclusively locked file" do @file.flock File::LOCK_EX - out = ruby_exe(<<-END_OF_CODE, escape: true) + out = ruby_exe(<<-END_OF_CODE) running = false t = Thread.new do diff --git a/spec/ruby/core/kernel/exec_spec.rb b/spec/ruby/core/kernel/exec_spec.rb index 1b4a7ae6f487..3d9520ad67a6 100644 --- a/spec/ruby/core/kernel/exec_spec.rb +++ b/spec/ruby/core/kernel/exec_spec.rb @@ -7,12 +7,12 @@ end it "runs the specified command, replacing current process" do - ruby_exe('exec "echo hello"; puts "fail"', escape: true).should == "hello\n" + ruby_exe('exec "echo hello"; puts "fail"').should == "hello\n" end end describe "Kernel.exec" do it "runs the specified command, replacing current process" do - ruby_exe('Kernel.exec "echo hello"; puts "fail"', escape: true).should == "hello\n" + ruby_exe('Kernel.exec "echo hello"; puts "fail"').should == "hello\n" end end diff --git a/spec/ruby/core/process/exec_spec.rb b/spec/ruby/core/process/exec_spec.rb index deb8913b6bcf..0f308a1986bb 100644 --- a/spec/ruby/core/process/exec_spec.rb +++ b/spec/ruby/core/process/exec_spec.rb @@ -34,16 +34,16 @@ end it "runs the specified command, replacing current process" do - ruby_exe('Process.exec "echo hello"; puts "fail"', escape: true).should == "hello\n" + ruby_exe('Process.exec "echo hello"; puts "fail"').should == "hello\n" end it "sets the current directory when given the :chdir option" do tmpdir = tmp("")[0..-2] platform_is_not :windows do - ruby_exe("Process.exec(\"pwd\", chdir: #{tmpdir.inspect})", escape: true).should == "#{tmpdir}\n" + ruby_exe("Process.exec(\"pwd\", chdir: #{tmpdir.inspect})").should == "#{tmpdir}\n" end platform_is :windows do - ruby_exe("Process.exec(\"cd\", chdir: #{tmpdir.inspect})", escape: true).tr('\\', '/').should == "#{tmpdir}\n" + ruby_exe("Process.exec(\"cd\", chdir: #{tmpdir.inspect})").tr('\\', '/').should == "#{tmpdir}\n" end end @@ -73,13 +73,13 @@ platform_is_not :windows do it "subjects the specified command to shell expansion" do result = Dir.chdir(@dir) do - ruby_exe('Process.exec "echo *"', escape: true) + ruby_exe('Process.exec "echo *"') end result.chomp.should == @name end it "creates an argument array with shell parsing semantics for whitespace" do - ruby_exe('Process.exec "echo a b c d"', escape: true).should == "a b c d\n" + ruby_exe('Process.exec "echo a b c d"').should == "a b c d\n" end end @@ -87,13 +87,13 @@ # There is no shell expansion on Windows it "does not subject the specified command to shell expansion on Windows" do result = Dir.chdir(@dir) do - ruby_exe('Process.exec "echo *"', escape: true) + ruby_exe('Process.exec "echo *"') end result.should == "*\n" end it "does not create an argument array with shell parsing semantics for whitespace on Windows" do - ruby_exe('Process.exec "echo a b c d"', escape: true).should == "a b c d\n" + ruby_exe('Process.exec "echo a b c d"').should == "a b c d\n" end end @@ -105,7 +105,7 @@ platform_is :windows do cmd = '"cmd.exe", "/C", "echo", "*"' end - ruby_exe("Process.exec #{cmd}", escape: true).should == "*\n" + ruby_exe("Process.exec #{cmd}").should == "*\n" end end @@ -124,29 +124,29 @@ end it "sets environment variables in the child environment" do - ruby_exe('Process.exec({"FOO" => "BAR"}, "echo ' + var + '")', escape: true).should == "BAR\n" + ruby_exe('Process.exec({"FOO" => "BAR"}, "echo ' + var + '")').should == "BAR\n" end it "unsets environment variables whose value is nil" do platform_is_not :windows do - ruby_exe('Process.exec({"FOO" => nil}, "echo ' + var + '")', escape: true).should == "\n" + ruby_exe('Process.exec({"FOO" => nil}, "echo ' + var + '")').should == "\n" end platform_is :windows do # On Windows, echo-ing a non-existent env var is treated as echo-ing any other string of text - ruby_exe('Process.exec({"FOO" => nil}, "echo ' + var + '")', escape: true).should == var + "\n" + ruby_exe('Process.exec({"FOO" => nil}, "echo ' + var + '")').should == var + "\n" end end it "coerces environment argument using to_hash" do - ruby_exe('o = Object.new; def o.to_hash; {"FOO" => "BAR"}; end; Process.exec(o, "echo ' + var + '")', escape: true).should == "BAR\n" + ruby_exe('o = Object.new; def o.to_hash; {"FOO" => "BAR"}; end; Process.exec(o, "echo ' + var + '")').should == "BAR\n" end it "unsets other environment variables when given a true :unsetenv_others option" do platform_is_not :windows do - ruby_exe('Process.exec("echo ' + var + '", unsetenv_others: true)', escape: true).should == "\n" + ruby_exe('Process.exec("echo ' + var + '", unsetenv_others: true)').should == "\n" end platform_is :windows do - ruby_exe('Process.exec("' + ENV['COMSPEC'].gsub('\\', '\\\\\\') + ' /C echo ' + var + '", unsetenv_others: true)', escape: true).should == var + "\n" + ruby_exe('Process.exec("' + ENV['COMSPEC'].gsub('\\', '\\\\\\') + ' /C echo ' + var + '", unsetenv_others: true)').should == var + "\n" end end end @@ -154,19 +154,19 @@ describe "with a command array" do it "uses the first element as the command name and the second as the argv[0] value" do platform_is_not :windows do - ruby_exe('Process.exec(["/bin/sh", "argv_zero"], "-c", "echo $0")', escape: true).should == "argv_zero\n" + ruby_exe('Process.exec(["/bin/sh", "argv_zero"], "-c", "echo $0")').should == "argv_zero\n" end platform_is :windows do - ruby_exe('Process.exec(["cmd.exe", "/C"], "/C", "echo", "argv_zero")', escape: true).should == "argv_zero\n" + ruby_exe('Process.exec(["cmd.exe", "/C"], "/C", "echo", "argv_zero")').should == "argv_zero\n" end end it "coerces the argument using to_ary" do platform_is_not :windows do - ruby_exe('o = Object.new; def o.to_ary; ["/bin/sh", "argv_zero"]; end; Process.exec(o, "-c", "echo $0")', escape: true).should == "argv_zero\n" + ruby_exe('o = Object.new; def o.to_ary; ["/bin/sh", "argv_zero"]; end; Process.exec(o, "-c", "echo $0")').should == "argv_zero\n" end platform_is :windows do - ruby_exe('o = Object.new; def o.to_ary; ["cmd.exe", "/C"]; end; Process.exec(o, "/C", "echo", "argv_zero")', escape: true).should == "argv_zero\n" + ruby_exe('o = Object.new; def o.to_ary; ["cmd.exe", "/C"]; end; Process.exec(o, "/C", "echo", "argv_zero")').should == "argv_zero\n" end end @@ -200,7 +200,7 @@ end EOC - ruby_exe(cmd, escape: true) + ruby_exe(cmd) child_fd = IO.read(@child_fd_file).to_i child_fd.to_i.should > STDERR.fileno @@ -216,7 +216,7 @@ Process.exec("#{ruby_cmd(map_fd_fixture)} \#{f.fileno}", f.fileno => f.fileno) EOC - output = ruby_exe(cmd, escape: true) + output = ruby_exe(cmd) child_fd, close_on_exec = output.split child_fd.to_i.should > STDERR.fileno @@ -232,7 +232,7 @@ puts(f.close_on_exec?) EOC - output = ruby_exe(cmd, escape: true) + output = ruby_exe(cmd) output.split.should == ['true', 'false'] end end diff --git a/spec/ruby/language/alias_spec.rb b/spec/ruby/language/alias_spec.rb index ee928cbfaae2..61fddb018496 100644 --- a/spec/ruby/language/alias_spec.rb +++ b/spec/ruby/language/alias_spec.rb @@ -252,7 +252,7 @@ def test_with_check(*args) it "on top level defines the alias on Object" do # because it defines on the default definee / current module - ruby_exe("def foo; end; alias bla foo; print method(:bla).owner", escape: true).should == "Object" + ruby_exe("def foo; end; alias bla foo; print method(:bla).owner").should == "Object" end it "raises a NameError when passed a missing name" do diff --git a/spec/tags/core/kernel/exec_tags.txt b/spec/tags/core/kernel/exec_tags.txt index 8884193ea59b..ed2e6189962e 100644 --- a/spec/tags/core/kernel/exec_tags.txt +++ b/spec/tags/core/kernel/exec_tags.txt @@ -1,2 +1,4 @@ slow:Kernel#exec runs the specified command, replacing current process slow:Kernel.exec runs the specified command, replacing current process +execve:Kernel#exec runs the specified command, replacing current process +execve:Kernel.exec runs the specified command, replacing current process diff --git a/spec/tags/core/process/exec_tags.txt b/spec/tags/core/process/exec_tags.txt index 083eaac6164f..6308b484654a 100644 --- a/spec/tags/core/process/exec_tags.txt +++ b/spec/tags/core/process/exec_tags.txt @@ -20,3 +20,28 @@ slow:Process.exec with a command array raises an ArgumentError if the Array does slow:Process.exec with an options Hash with Integer option keys lets the process after exec have specified file descriptor despite close_on_exec slow:Process.exec with an options Hash with Integer option keys sets close_on_exec to false on specified fd even when it fails slow:Process.exec with an options Hash with Integer option keys maps the key to a file descriptor in the child that inherits the file descriptor from the parent specified by the value +execve:Process.exec raises Errno::ENOENT for an empty string +execve:Process.exec raises Errno::ENOENT for a command which does not exist +execve:Process.exec raises an ArgumentError if the command includes a null byte +execve:Process.exec raises Errno::EACCES when the file does not have execute permissions +execve:Process.exec raises Errno::EACCES or Errno::ENOEXEC when the file is not an executable file +execve:Process.exec raises Errno::EACCES when passed a directory +execve:Process.exec runs the specified command, replacing current process +execve:Process.exec sets the current directory when given the :chdir option +execve:Process.exec flushes STDOUT upon exit when it's not set to sync +execve:Process.exec flushes STDERR upon exit when it's not set to sync +execve:Process.exec with a single argument subjects the specified command to shell expansion +execve:Process.exec with a single argument creates an argument array with shell parsing semantics for whitespace +execve:Process.exec with a single argument does not subject the specified command to shell expansion on Windows +execve:Process.exec with a single argument does not create an argument array with shell parsing semantics for whitespace on Windows +execve:Process.exec with multiple arguments does not subject the arguments to shell expansion +execve:Process.exec (environment variables) sets environment variables in the child environment +execve:Process.exec (environment variables) unsets environment variables whose value is nil +execve:Process.exec (environment variables) coerces environment argument using to_hash +execve:Process.exec (environment variables) unsets other environment variables when given a true :unsetenv_others option +execve:Process.exec with a command array uses the first element as the command name and the second as the argv[0] value +execve:Process.exec with a command array coerces the argument using to_ary +execve:Process.exec with a command array raises an ArgumentError if the Array does not have exactly two elements +execve:Process.exec with an options Hash with Integer option keys maps the key to a file descriptor in the child that inherits the file descriptor from the parent specified by the value +execve:Process.exec with an options Hash with Integer option keys lets the process after exec have specified file descriptor despite close_on_exec +execve:Process.exec with an options Hash with Integer option keys sets close_on_exec to false on specified fd even when it fails diff --git a/spec/tags/truffle/launcher_tags.txt b/spec/tags/truffle/launcher_tags.txt index 8d7087a3a927..ebb1f910f099 100644 --- a/spec/tags/truffle/launcher_tags.txt +++ b/spec/tags/truffle/launcher_tags.txt @@ -82,3 +82,7 @@ slow:The launcher supports running rdoc in bin/ slow:The launcher supports running ri in bin/ slow:The launcher supports running ruby in bin/ slow:The launcher supports running truffleruby in bin/ +execve:The launcher runtime configuration flags should recognize ruby --vm options in RUBYOPT when switching to JVM +execve:The launcher runtime configuration flags should recognize ruby --vm options in TRUFFLERUBYOPT when switching to JVM +execve:The launcher runtime configuration flags switches to JVM with --jvm as a Ruby argument +execve:The launcher runtime configuration flags keeps --jvm as an application argument if given as an application argument diff --git a/spec/truffle/launcher_spec.rb b/spec/truffle/launcher_spec.rb index 6600013181af..270153e0fc41 100644 --- a/spec/truffle/launcher_spec.rb +++ b/spec/truffle/launcher_spec.rb @@ -44,7 +44,7 @@ @redirect = "2>#{@stderr}" # GR-23507, GR-44103: prevent thread warnings on stdout to break specs/tests - @ignore_jvm_thread_warnings = '--vm.Xlog:os+thread=off' + @ignore_jvm_thread_warnings = '--vm.Xlog:os+thread=off,gc+task=off' end after :each do diff --git a/spec/truffleruby.mspec b/spec/truffleruby.mspec index 9c9f988665f0..05121943d252 100644 --- a/spec/truffleruby.mspec +++ b/spec/truffleruby.mspec @@ -121,6 +121,10 @@ class MSpecScript excludes << 'native' if GC.heap_stats.values.none?(Hash) excludes << 'native-g1' + # GR-23507: exclude specs using execve() as concurrent pthread_create() + # return EAGAIN and cause extra logging on stdout, + # and -Xlog configuration is not available yet on Native Image. + excludes << 'execve' end else excludes << 'jvm' diff --git a/tool/jt.rb b/tool/jt.rb index 64eda2760193..cd4aabd5ade9 100755 --- a/tool/jt.rb +++ b/tool/jt.rb @@ -1087,16 +1087,15 @@ def rebuild(*options) # The problem happens if one thread is calling execve() and the other about the same time is calling pthread_create(). # In such case, pthread_create() can return EAGAIN "just because there is a concurrent execve()". # See https://bugs.openjdk.org/browse/JDK-8268605?focusedCommentId=14473665#comment-14473665 - # To solve this we move VM warnings to stderr instead of stdout to avoid breaking specs, and logging should be on stderr anyway. - # '--vm.Xlog:os+thread=off' '--vm.Xlog:gc+task=off' would also be a possibility, but unfortunately - # these flags don't seem to combine with moving all warnings to stderr so we have to pick one approach. + # To ignore those warnings we use '--vm.Xlog:os+thread=off,gc+task=off'. + # --vm.Xlog:all=warning:stderr could be nice but for some reason that can end up causing a warning on stderr AND stdout, which fails specs. # Example warnings: # JVM: # [11.028s][warning][os,thread] Failed to start thread - pthread_create failed (EAGAIN) for attributes: stacksize: 2048k, guardsize: 0k, detached. # SVM with G1: # [0.094s][warning][os,thread] Failed to start thread "GC Thread#1" - pthread_create failed (EAGAIN) for attributes: stacksize: 1024k, guardsize: 4k, detached. # [0.094s][error ][gc,task ] GC(0) Failed to create worker thread - vm_args << '--vm.Xlog:all=warning:stderr' + vm_args << '--vm.Xlog:os+thread=off,gc+task=off' end [vm_args, ruby_args + args, options] From 52dede917fde86840f3139a21f89f688305d6467 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Mon, 4 Sep 2023 20:05:04 +0000 Subject: [PATCH 3/4] [GR-46399] Disable generation of debuginfo. PullRequest: truffleruby/3987 (cherry picked from commit 45c60f85b028c53f1a519637bc69aa4333042704) --- mx.truffleruby/native | 1 + mx.truffleruby/native-ee | 1 + mx.truffleruby/native-ee-aux | 1 + mx.truffleruby/native-host-inlining | 1 + 4 files changed, 4 insertions(+) diff --git a/mx.truffleruby/native b/mx.truffleruby/native index 303ffc97e0ce..f564a314a044 100644 --- a/mx.truffleruby/native +++ b/mx.truffleruby/native @@ -3,6 +3,7 @@ DYNAMIC_IMPORTS=/tools,/compiler,/substratevm COMPONENTS=TruffleRuby,suite:tools,GraalVM compiler,SubstrateVM,Truffle Macro NATIVE_IMAGES=suite:sulong,lib:rubyvm EXTRA_IMAGE_BUILDER_ARGUMENTS=rubyvm:-H:+UnlockExperimentalVMOptions rubyvm:-H:BuildOutputJSONFile=native-image-build-rubyvm.json rubyvm:-H:-UnlockExperimentalVMOptions +GENERATE_DEBUGINFO=false # To also create the standalone INSTALLABLES=TruffleRuby BUILD_TARGETS=GRAALVM,GRAALVM_STANDALONES diff --git a/mx.truffleruby/native-ee b/mx.truffleruby/native-ee index c7923a6812e8..44fa1dfb7034 100644 --- a/mx.truffleruby/native-ee +++ b/mx.truffleruby/native-ee @@ -3,6 +3,7 @@ DYNAMIC_IMPORTS=/tools,/truffleruby-enterprise,/graal-enterprise,/substratevm-en COMPONENTS=TruffleRuby,suite:tools,GraalVM enterprise compiler,Truffle enterprise,SubstrateVM Enterprise,Truffle Macro Enterprise,suite:substratevm-enterprise-gcs NATIVE_IMAGES=suite:sulong,lib:rubyvm EXTRA_IMAGE_BUILDER_ARGUMENTS=rubyvm:-H:+UnlockExperimentalVMOptions rubyvm:-H:BuildOutputJSONFile=native-image-build-rubyvm.json rubyvm:-H:-UnlockExperimentalVMOptions +GENERATE_DEBUGINFO=false # To also create the standalone INSTALLABLES=TruffleRuby BUILD_TARGETS=GRAALVM,GRAALVM_STANDALONES diff --git a/mx.truffleruby/native-ee-aux b/mx.truffleruby/native-ee-aux index c184fdc909e8..328ab80e90bb 100644 --- a/mx.truffleruby/native-ee-aux +++ b/mx.truffleruby/native-ee-aux @@ -3,6 +3,7 @@ DYNAMIC_IMPORTS=/tools,/truffleruby-enterprise,/graal-enterprise,/substratevm-en COMPONENTS=TruffleRuby,suite:tools,GraalVM enterprise compiler,Truffle enterprise,SubstrateVM Enterprise,Truffle Macro Enterprise NATIVE_IMAGES=suite:sulong,lib:rubyvm EXTRA_IMAGE_BUILDER_ARGUMENTS=rubyvm:-H:+UnlockExperimentalVMOptions rubyvm:-H:BuildOutputJSONFile=native-image-build-rubyvm.json rubyvm:-H:-UnlockExperimentalVMOptions rubyvm:-H:+AuxiliaryEngineCache rubyvm:-H:ReservedAuxiliaryImageBytes=1073741824 +GENERATE_DEBUGINFO=false NATIVE_IMAGE_AUXILIARY_ENGINE_CACHE=true # To also create the standalone INSTALLABLES=TruffleRuby diff --git a/mx.truffleruby/native-host-inlining b/mx.truffleruby/native-host-inlining index 0bde85347da1..9f605365ff24 100644 --- a/mx.truffleruby/native-host-inlining +++ b/mx.truffleruby/native-host-inlining @@ -3,6 +3,7 @@ DYNAMIC_IMPORTS=/tools,/compiler,/substratevm COMPONENTS=TruffleRuby,suite:tools,GraalVM compiler,SubstrateVM,Truffle Macro NATIVE_IMAGES=lib:rubyvm EXTRA_IMAGE_BUILDER_ARGUMENTS=rubyvm:-H:+UnlockExperimentalVMOptions rubyvm:-H:BuildOutputJSONFile=native-image-build-rubyvm.json rubyvm:-H:Log=HostInliningPhase,~CanonicalizerPhase,~GraphBuilderPhase rubyvm:-H:+TruffleHostInliningPrintExplored rubyvm:-H:-UnlockExperimentalVMOptions rubyvm:-Dgraal.LogFile=host-inlining.txt +GENERATE_DEBUGINFO=false # To also create the standalone INSTALLABLES=TruffleRuby BUILD_TARGETS=GRAALVM,GRAALVM_STANDALONES From eed858a538e08fd6a0fd4e909c0014f2f1cb85b5 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Mon, 4 Sep 2023 22:58:07 +0000 Subject: [PATCH 4/4] [GR-17457] Fail early if truffleruby jars are run on Windows PullRequest: truffleruby/3975 (cherry picked from commit 26231c4030553eebad6b68cc5305f7604441b93f) --- .../org/truffleruby/core/support/IONodes.java | 24 +++++++------------ .../org/truffleruby/platform/Platform.java | 4 ---- .../org/truffleruby/shared/BasicPlatform.java | 16 ++++--------- 3 files changed, 12 insertions(+), 32 deletions(-) diff --git a/src/main/java/org/truffleruby/core/support/IONodes.java b/src/main/java/org/truffleruby/core/support/IONodes.java index ec425502a6fa..6c497bee0c89 100644 --- a/src/main/java/org/truffleruby/core/support/IONodes.java +++ b/src/main/java/org/truffleruby/core/support/IONodes.java @@ -87,7 +87,6 @@ import org.truffleruby.language.control.RaiseException; import org.truffleruby.language.library.RubyStringLibrary; import org.truffleruby.language.objects.AllocationTracing; -import org.truffleruby.platform.Platform; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -153,9 +152,6 @@ boolean fnmatch(Object pattern, Object path, int flags, flags) != FNM_NOMATCH; } - - private static final boolean DOSISH = Platform.IS_WINDOWS; - private static final int FNM_NOESCAPE = 0x01; private static final int FNM_PATHNAME = 0x02; private static final int FNM_DOTMATCH = 0x04; @@ -164,7 +160,7 @@ boolean fnmatch(Object pattern, Object path, int flags, public static final int FNM_NOMATCH = 1; private static boolean isdirsep(char c) { - return c == '/' || DOSISH && c == '\\'; + return c == '/'; } private static boolean isdirsep(byte c) { @@ -259,19 +255,15 @@ private static int fnmatch_helper(byte[] bytes, int pstart, int pend, byte[] str if (s >= send) { return FNM_NOMATCH; } - if (DOSISH && (pathname && isdirsep(c) && isdirsep(string[s]))) { - } else { - if (nocase) { - if (Character.toLowerCase(c) != Character.toLowerCase((char) string[s])) { - return FNM_NOMATCH; - } - - } else { - if (c != (char) (string[s] & 0xFF)) { - return FNM_NOMATCH; - } + if (nocase) { + if (Character.toLowerCase(c) != Character.toLowerCase((char) string[s])) { + return FNM_NOMATCH; } + } else { + if (c != (char) (string[s] & 0xFF)) { + return FNM_NOMATCH; + } } s++; break; diff --git a/src/main/java/org/truffleruby/platform/Platform.java b/src/main/java/org/truffleruby/platform/Platform.java index cbf1836ce059..8104889ef5b9 100644 --- a/src/main/java/org/truffleruby/platform/Platform.java +++ b/src/main/java/org/truffleruby/platform/Platform.java @@ -35,12 +35,8 @@ public abstract class Platform extends BasicPlatform { public static final String LIB_SUFFIX = determineLibSuffix(); public static final String CEXT_SUFFIX = OS == OS_TYPE.DARWIN ? ".bundle" : LIB_SUFFIX; - public static final boolean IS_WINDOWS = OS == OS_TYPE.WINDOWS; - private static String determineLibSuffix() { switch (OS) { - case WINDOWS: - return ".dll"; case DARWIN: return ".dylib"; default: diff --git a/src/shared/java/org/truffleruby/shared/BasicPlatform.java b/src/shared/java/org/truffleruby/shared/BasicPlatform.java index af281e425fa5..a3e0ec35d7ca 100644 --- a/src/shared/java/org/truffleruby/shared/BasicPlatform.java +++ b/src/shared/java/org/truffleruby/shared/BasicPlatform.java @@ -41,9 +41,7 @@ public abstract class BasicPlatform { public enum OS_TYPE { LINUX("linux"), - DARWIN("darwin"), - SOLARIS("solaris"), - WINDOWS("mswin32"); + DARWIN("darwin"); private final String rubyName; @@ -54,8 +52,7 @@ public enum OS_TYPE { public enum ARCH { AMD64("x86_64"), - AARCH64("aarch64"), - UNKNOWN("unknown"); + AARCH64("aarch64"); private final String rubyName; @@ -79,14 +76,9 @@ public static OS_TYPE determineOS() { final String osName = System.getProperty("os.name"); final String lowerOSName = osName.toLowerCase(Locale.ENGLISH); - if (lowerOSName.contains("windows")) { - return OS_TYPE.WINDOWS; - } if (lowerOSName.startsWith("mac") || lowerOSName.startsWith("darwin")) { return OS_TYPE.DARWIN; - } else if (lowerOSName.startsWith("sunos") || lowerOSName.startsWith("solaris")) { - return OS_TYPE.SOLARIS; } final String upperOSName = osName.toUpperCase(Locale.ENGLISH); @@ -96,7 +88,7 @@ public static OS_TYPE determineOS() { } } - throw new UnsupportedOperationException("Unknown platform: " + osName); + throw new UnsupportedOperationException("Unsupported operating system: " + osName); } private static ARCH determineArchitecture() { @@ -110,7 +102,7 @@ private static ARCH determineArchitecture() { case "arm64": return ARCH.AARCH64; default: - return ARCH.UNKNOWN; + throw new UnsupportedOperationException("Unsupported CPU architecture: " + architecture); } }