-
Notifications
You must be signed in to change notification settings - Fork 143
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
Fall back to default AR and CC #2725
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,15 +40,34 @@ def generate_templates | |
end | ||
end | ||
|
||
# We're going to need to run `make` using prism's `Makefile`. We want to match | ||
# up as much of the configuration to the configuration that built the current | ||
# version of Ruby as possible. | ||
require "rbconfig" | ||
env = RbConfig::CONFIG.slice("SOEXT", "CPPFLAGS", "CFLAGS", "CC", "AR", "ARFLAGS", "MAKEDIRS", "RMALL") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
# It's possible that the Ruby that is being run wasn't actually compiled on this | ||
# machine, in which case the configuration might be incorrect. In this case | ||
# we'll need to do some additional checks and potentially fall back to defaults. | ||
if env.key?("CC") && !File.exist?(env["CC"]) | ||
env.delete("CC") | ||
env.delete("CFLAGS") | ||
env.delete("CPPFLAGS") | ||
end | ||
|
||
if env.key?("AR") && !File.exist?(env["AR"]) | ||
env.delete("AR") | ||
env.delete("ARFLAGS") | ||
end | ||
|
||
# Runs `make` in the root directory of the project. Note that this is the | ||
# `Makefile` for the overall project, not the `Makefile` that is being generated | ||
# by this script.` | ||
def make(target) | ||
def make(env, target) | ||
puts "Running make #{target} with #{env.inspect}" | ||
Dir.chdir(File.expand_path("../..", __dir__)) do | ||
system( | ||
RbConfig::CONFIG.slice(*%w[SOEXT CPPFLAGS CFLAGS CC AR ARFLAGS MAKEDIRS RMALL]), # env | ||
env, | ||
RUBY_PLATFORM.include?("openbsd") ? "gmake" : "make", | ||
target, | ||
exception: true | ||
|
@@ -62,7 +81,7 @@ def make(target) | |
# but we want to use the native toolchain here since libprism is run natively. | ||
if RUBY_ENGINE != "ruby" | ||
generate_templates | ||
make("build/libprism.#{RbConfig::CONFIG["SOEXT"]}") | ||
make(env, "build/libprism.#{RbConfig::CONFIG["SOEXT"]}") | ||
File.write("Makefile", "all install clean:\n\t@#{RbConfig::CONFIG["NULLCMD"]}\n") | ||
return | ||
end | ||
|
@@ -110,7 +129,7 @@ def make(target) | |
archive_target = "build/libprism.a" | ||
archive_path = File.expand_path("../../#{archive_target}", __dir__) | ||
|
||
make(archive_target) unless File.exist?(archive_path) | ||
make(env, archive_target) unless File.exist?(archive_path) | ||
$LOCAL_LIBS << " #{archive_path}" | ||
|
||
# Finally, we'll create the `Makefile` that is going to be used to configure and | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discovered in #2711 (comment),
CC ?= cc
andAR ?= ar
has no effect, whether run frommake
directly (because GNUmake
already preconfigures them tocc
andar
respectively) or fromextconf.rb
(as it’ll override them withrbconfig
values)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you in theory, but something else must be going on here, because after lots of back and forth with @forthrin this is what finally resolved the issue. I'm assuming there's something else here going on.