Fixed 32bit Linux builds on 32bit Linux.
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 07 Jun 2016 19:04:39 +0100
changeset 35 9d3a72ddb471
parent 34 660408d5e161
child 36 2d53d5e44347
Fixed 32bit Linux builds on 32bit Linux. Sigh, another hack here. For an unknown reason eXept added `-Wl,--wrap=memcpy` linker flag. This not only hinders performace [*] but also causes infinite recursion when in use. Wonder if it ever worked. So, yet another hack here: remove the `--wrap=memcpy` from linker flags. [*] under GCC, memcpy() translates to a rather fast intrinsic.
rakelib/compile.rake
rakelib/extensions.rb
--- a/rakelib/compile.rake	Tue Jun 07 18:12:40 2016 +0100
+++ b/rakelib/compile.rake	Tue Jun 07 19:04:39 2016 +0100
@@ -227,6 +227,13 @@
 
     task STX_CONF_DIR / 'vendorConf' do
       cp STX_CONF_DIR / 'linux-elf' / 'COMMON' / 'defines' , STX_CONF_DIR / 'vendorConf'
+      # Sigh, another hack here. For an unknown reason eXept added -Wl,--wrap=memcpy linker
+      # flag. This not only hinders performace [*] but also causes infinite recursion when
+      # in use. Wonder if it ever worked. So, yet another hack here: remove the 
+      # `--wrap=memcpy` from linker flags.
+      #
+      # [*] under GCC, memcpy() translates to a rather fast intrinsic. 
+      sed(',--wrap=memcpy', '', STX_CONF_DIR / 'vendorConf', true)
     end
 
     task STX_CONF_DIR / 'myConf' do
@@ -260,7 +267,7 @@
           f.puts 'OPTIONAL_FFI_TARGET_IN_LIBRUN=ffi'
           f.puts 'FFI_CC="$(CC) -m64 -fPIC"'
           f.puts 'FFI_LD="ld -m elf_x84_64"'
-        end        
+        end
       end
     end
   when win32?
--- a/rakelib/extensions.rb	Tue Jun 07 18:12:40 2016 +0100
+++ b/rakelib/extensions.rb	Tue Jun 07 19:04:39 2016 +0100
@@ -208,6 +208,20 @@
     end
   end
 
+  # Pretty much like sed. Replaces all occurences of `pattern` by `replacement` in given `file`.
+  # If `inplace` is `true`, then the modified contents is written back to the file. Otherwise it
+  # printed on `STDOUT`.
+  def sed(pattern, replacement, file, inplace = false)
+    contents = File.read(file)
+    contents.gsub!(pattern, replacement)
+    if inplace then
+      cp file, "#{file}.bak"
+      File.open(file, "w") { | f | f.puts contents }
+    else
+      STDOUT.puts contents
+    end
+  end
+  
   # Create a compressed archive of `source`. Under Windows it creates
   # `.zip` archive, otherwise (on Linux) it creates `tar.bz2`. 
   #