You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the following rake command to compile a native extension with rake-compiler gem, where the extra options whose value (--with-cflags='-Wundef -Werror') includes a space, in this case -Wundef -Werror is printed without quotes. And the command is different from the one actually executed and it's not reproducible.
I am using the following my environment on Fedora Linux 37. I think this issue doesn't depend on the specific version of the Ruby. I would share it with you just in case.
$ ruby -v
ruby 3.3.0dev (2023-05-25T12:45:21Z wip/mkmf-verbose-r.. cbeba2ed16) [x86_64-linux]
$ which gem
~/.local/ruby-cbeba2ed16/bin/gem
$ gem -v
3.5.0.dev
$ which bundle
~/.local/ruby-cbeba2ed16/bin/bundle
$ bundle -v
Bundler version 2.5.0.dev
Ran the rake with the rake-compiler gem. The following command is to compile the native extension setting the -Wundef -Werror as compiler flags. You see the command propagates the -Wundef -Werror to the gcc command lines. It's important to run with the rake-compiler latest stable version 1.2.2. Because it fixes rake-compiler/rake-compiler#215 related to this issue. The environment variable MAKEFLAGS reserved in the GNU make is to print the compiler command lines.
The problem is the the line /home/jaruga/.local/ruby-cbeba2ed16/bin/ruby -I. -r.rake-compiler-siteconf.rb ../../../../ext/openssl/extconf.rb -- --with-cflags=-Wundef -Werror printed at sh in the lib/rake/extensiontask.rb. Because the --with-cflags=-Wundef -Werror is different from the one actually executed, and not reproducible. The argument --with-cflags's value is -Wundef -Werror. It should be printed as --with-cflags="-Wundef -Werror" with quotes.
Debug
I debugged with debug gem. Added the gem "debug" to the ruby/openssl's Gemfile.
$ pwd
/home/jaruga/git/ruby/openssl
$ vi Gemefile
$ bundle update
Next set the breakpoint before the sh method to print and execute the command.
$ cd /home/jaruga/git/ruby/openssl/bundle/ruby/3.3.0+0/gems/rake-compiler-1.2.2/lib/rake
$ pwd
/home/jaruga/git/ruby/openssl/bundle/ruby/3.3.0+0/gems/rake-compiler-1.2.2/lib/rake
$ diff -u extensiontask.rb.orig extensiontask.rb
--- extensiontask.rb.orig 2023-05-26 20:36:06.207487491 +0200
+++ extensiontask.rb 2023-05-26 21:14:35.794188802 +0200
@@ -215,6 +215,9 @@
end
chdir tmp_path do
+ require 'debug'
+ binding.break
+
sh *cmd
end
end
Went back to the ruby/openssl, and cleaned the built files.
$ MAKEFLAGS="V=1" bundle exec rake compile -- --with-cflags='-Wundef -Werror'
...
(rdbg) f # frame command
=> 219| binding.break
=>#0 block in define_compile_tasks (2 levels) at ~/var/git/ruby/openssl/bundle/ruby/3.3.0+0/gems/rake-compiler-1.2.2/lib/rake/extensiontask.rb:219
(rdbg) p cmd # command
=> ["/home/jaruga/.local/ruby-cbeba2ed16/bin/ruby", "-I.", "-r.rake-compiler-siteconf.rb", "../../../../ext/openssl/extconf.rb", "--", "--with-cflags=-Wundef -Werror"]
...
The lib/rake/file_utils.rb#sh calling Rake.rake_output_message sh_show_command cmd. And the cmd.join " " in the sh_show_command causes this issue. Is it a bug?
(rdbg) n # next command
[77, 86] in ~/var/git/ruby/openssl/bundle/ruby/3.3.0+0/gems/rake-13.0.6/lib/rake/file_utils.rb
77| env = cmd.first
78| env = env.map { |name, value| "#{name}=#{value}" }.join " "
79| cmd[0] = env
80| end
81|
=> 82| cmd.join " "
83| end
84| private :sh_show_command
85|
86| def set_verbose_option(options) # :nodoc:
Summary
In the following
rake
command to compile a native extension withrake-compiler
gem, where the extra options whose value (--with-cflags='-Wundef -Werror'
) includes a space, in this case-Wundef -Werror
is printed without quotes. And the command is different from the one actually executed and it's not reproducible.I think quotes (double quotes or single quotes) are needed like the command below.
Note that @kou helped me to report this issue here at rake-compiler/rake-compiler#215 (comment).
My environment
I am using the following my environment on Fedora Linux 37. I think this issue doesn't depend on the specific version of the Ruby. I would share it with you just in case.
Reproducing steps
Here are the reproducing steps with the ruby/openssl: https://github.com/ruby/openssl first.
Ran the
rake
with therake-compiler
gem. The following command is to compile the native extension setting the-Wundef -Werror
as compiler flags. You see the command propagates the-Wundef -Werror
to the gcc command lines. It's important to run with therake-compiler
latest stable version 1.2.2. Because it fixes rake-compiler/rake-compiler#215 related to this issue. The environment variableMAKEFLAGS
reserved in the GNU make is to print the compiler command lines.The problem is the the line
/home/jaruga/.local/ruby-cbeba2ed16/bin/ruby -I. -r.rake-compiler-siteconf.rb ../../../../ext/openssl/extconf.rb -- --with-cflags=-Wundef -Werror
printed atsh
in thelib/rake/extensiontask.rb
. Because the--with-cflags=-Wundef -Werror
is different from the one actually executed, and not reproducible. The argument--with-cflags
's value is-Wundef -Werror
. It should be printed as--with-cflags="-Wundef -Werror"
with quotes.Debug
I debugged with
debug
gem. Added thegem "debug"
to the ruby/openssl'sGemfile
.Next set the breakpoint before the
sh
method to print and execute the command.Went back to the ruby/openssl, and cleaned the built files.
And ran the command again.
The
lib/rake/file_utils.rb#sh
callingRake.rake_output_message sh_show_command cmd
. And thecmd.join " "
in thesh_show_command
causes this issue. Is it a bug?I would show you the backtrace command just in case.
The text was updated successfully, but these errors were encountered: