Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miniportile2 recipe.host is nil on windows in extconf.rb #506

Open
jmarrec opened this issue Feb 13, 2024 · 3 comments
Open

Miniportile2 recipe.host is nil on windows in extconf.rb #506

jmarrec opened this issue Feb 13, 2024 · 3 comments

Comments

@jmarrec
Copy link
Contributor

jmarrec commented Feb 13, 2024

It throws on this line as a result

unless File.exist?(File.join(recipe.target, recipe.host, recipe.name, recipe.version))

I do use a mswin built of ruby (ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x64-mswin64_140]) in this specific case, but I can reproduce using 2.7.2 mingw.

Miniportile2 uses the output of running gcc -v to detect the host, and obviously this fails in this case.

https://github.com/flavorjones/mini_portile/blob/52fb0bc41c89a10f1ac7b5abcf0157e059194374/lib/mini_portile2/mini_portile.rb#L542-L557

I am able to work around it by using the same code as nokogiri: https://github.com/sparklemotion/nokogiri/blob/d7ee3b683246a9fdc19c51aabc98868dc8dcf134/ext/nokogiri/extconf.rb#L443-L446

    # We use 'host' to set compiler prefix for cross-compiling. Prefer host_alias over host. And
    # prefer i686 (what external dev tools use) to i386 (what ruby's configure.ac emits).
    recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
    recipe.host = recipe.host.gsub("i386", "i686")
@flavorjones
Copy link
Member

@jmarrec Sorry you're having problems.

Miniportile's gcc_cmd in your case isn't actually gcc, it's your compiler:

  def gcc_cmd
    (ENV["CC"] || @gcc_command || RbConfig::CONFIG["CC"] || "gcc").dup
  end

What does your compiler emit when given a -v option? Can you recommend something as an alternative to detect the host string?

@jmarrec
Copy link
Contributor Author

jmarrec commented Feb 14, 2024

@flavorjones I appreciate the quick answer, thank you.

Note that I've worked around it already by using --enable-system-libraries --with-pkg-config=pkgconf (I have pkgconf in my PATH and I've set PKG_CONFIG_PATH to a location where I do have sqlite3.pc) so it doesn't use miniportile2 at all.

$ ruby -e "puts RbConfig::CONFIG['CC']"
cl -nologo

$ cl -nologo -v 
cl : Command line warning D9002 : ignoring unknown option '-v'
cl : Command line error D8003 : missing source filename

# Whereas
$ cl -v 
Microsoft (R) C/C++ Optimizing Compiler Version 19.38.33135 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line warning D9002 : ignoring unknown option '-v'
cl : Command line error D8003 : missing source filename

(cl is C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.3310\bin\Hostx64\x64\cl.exe)

@jmarrec
Copy link
Contributor Author

jmarrec commented Feb 14, 2024

$ ruby -e "puts RbConfig::CONFIG['host_alias']"
x64-mswin64_140
$ ruby -e "puts RbConfig::CONFIG['host']"
x64-pc-mswin64_140

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@flavorjones @jmarrec and others