[前][次][番号順一覧][スレッド一覧]

ruby-changes:71577

From: Nobuyoshi <ko1@a...>
Date: Thu, 31 Mar 2022 21:35:05 +0900 (JST)
Subject: [ruby-changes:71577] af2ab0dd1c (master): [ruby/psych] Make a static library from PIC object files

https://git.ruby-lang.org/ruby.git/commit/?id=af2ab0dd1c

From af2ab0dd1c899356d9ec38b052f0df0706efb8f9 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Thu, 31 Mar 2022 19:29:24 +0900
Subject: [ruby/psych] Make a static library from PIC object files

On some platforms, PIC and non-PIC code are incompatible and the
latter cannot be used for shared objects.

https://github.com/ruby/psych/commit/5652e32733
---
 ext/psych/depend     | 4 ++++
 ext/psych/extconf.rb | 9 +++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ext/psych/depend b/ext/psych/depend
index 4947822c78..78bde9a53d 100644
--- a/ext/psych/depend
+++ b/ext/psych/depend
@@ -2,8 +2,12 @@ $(TARGET_SO): $(LIBYAML) https://github.com/ruby/ruby/blob/trunk/ext/psych/depend#L2
 
 libyaml $(LIBYAML):
 	cd libyaml && $(MAKE)
+	$(AR) $(ARFLAGS) $(LIBYAML) $(LIBYAML_OBJDIR)/*.$(OBJEXT)
+	$(RANLIB) $(LIBYAML)
+
 clean-so::
 	-cd libyaml && $(MAKE) clean
+
 distclean-so::
 	-cd libyaml && $(MAKE) distclean
 	-$(Q)$(RMDIRS) libyaml/* libyaml
diff --git a/ext/psych/extconf.rb b/ext/psych/extconf.rb
index f7e610ce88..54aa730f44 100644
--- a/ext/psych/extconf.rb
+++ b/ext/psych/extconf.rb
@@ -39,8 +39,9 @@ if yaml_source https://github.com/ruby/ruby/blob/trunk/ext/psych/extconf.rb#L39
   puts("Configuring libyaml source in #{yaml_source.quote}")
   yaml = "libyaml"
   Dir.mkdir(yaml) unless File.directory?(yaml)
+  shared = $enable_shared || !$static
   unless system(yaml_configure, "-q",
-                "--enable-#{$enable_shared || !$static ? 'shared' : 'static'}",
+                "--enable-#{shared ? 'shared' : 'static'}",
                 "--host=#{RbConfig::CONFIG['host'].sub(/-unknown-/, '-')}",
                 *(["CFLAGS=-w"] if RbConfig::CONFIG["GCC"] == "yes"),
                 chdir: yaml)
@@ -50,12 +51,16 @@ if yaml_source https://github.com/ruby/ruby/blob/trunk/ext/psych/extconf.rb#L51
   inc = yaml_source.start_with?("#$srcdir/") ? "$(srcdir)#{yaml_source[$srcdir.size..-1]}" : yaml_source
   $INCFLAGS << " -I#{yaml}/include -I#{inc}/include"
   Logging.message("INCLFAG=#$INCLFAG\n")
-  libyaml = "#{yaml}/src/.libs/libyaml.#$LIBEXT"
+  libyaml = "libyaml.#$LIBEXT"
+  $cleanfiles << libyaml
   $LOCAL_LIBS.prepend("$(LIBYAML) ")
 end
 
 create_makefile 'psych' do |mk|
   mk << "LIBYAML = #{libyaml}".strip << "\n"
+  mk << "LIBYAML_OBJDIR = libyaml/src#{shared ? '/.libs' : ''}\n"
+  mk << "OBJEXT = #$OBJEXT"
+  mk << "RANLIB = #{config_string('RANLIB') || config_string('NULLCMD')}\n"
 end
 
 # :startdoc:
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]