mirror of
https://github.com/void-linux/void-packages.git
synced 2025-06-05 06:33:50 +02:00
mruby: build for host with clang
Trying to build for i686 native with gcc, or trying to cross build with i686 as the host architecture, the build fails. This seems to be a problem with either i686 gcc or the binutils (linker). For now build with clang for native and for the host when cross compiling to work around the problems. TODO: find the real reason why the compiler or linker packages for i686 are broken and switch back to using gcc.
This commit is contained in:
parent
b9f815e1ab
commit
cdd806a989
1 changed files with 74 additions and 29 deletions
|
@ -1,8 +1,8 @@
|
||||||
# Template file for 'mruby'
|
# Template file for 'mruby'
|
||||||
pkgname=mruby
|
pkgname=mruby
|
||||||
version=2.1.0
|
version=2.1.0
|
||||||
revision=1
|
revision=2
|
||||||
hostmakedepends="bison ruby"
|
hostmakedepends="bison clang ruby"
|
||||||
short_desc="Lightweight implementation of the Ruby language (Ruby 1.9)"
|
short_desc="Lightweight implementation of the Ruby language (Ruby 1.9)"
|
||||||
maintainer="Jürgen Buchmüller <pullmoll@t-online.de>"
|
maintainer="Jürgen Buchmüller <pullmoll@t-online.de>"
|
||||||
license="MIT"
|
license="MIT"
|
||||||
|
@ -10,35 +10,59 @@ homepage="https://mruby.org/"
|
||||||
distfiles="https://github.com/mruby/mruby/archive/${version}.tar.gz>${pkgname}-${version}.tar.gz"
|
distfiles="https://github.com/mruby/mruby/archive/${version}.tar.gz>${pkgname}-${version}.tar.gz"
|
||||||
checksum=d6733742a07e553c52ab71df08b0604b3b571768bbc0c2729fbf0389d1bb5d13
|
checksum=d6733742a07e553c52ab71df08b0604b3b571768bbc0c2729fbf0389d1bb5d13
|
||||||
lib32disabled=yes
|
lib32disabled=yes
|
||||||
|
# I cannot get clang to link a PIE executable
|
||||||
|
nopie=yes
|
||||||
|
|
||||||
if [ "$XBPS_TARGET_WORDSIZE" = 32 ]; then
|
# Note: we use clang to build for the host because with gcc the build fails
|
||||||
broken="Currently fails to build for 32 bit architectures"
|
# for i686 (native) and also when i686 is the host architecture for cross builds.
|
||||||
fi
|
LIBS="m"
|
||||||
|
|
||||||
do_configure() {
|
do_configure() {
|
||||||
vsed -i mrbgems/mruby-compiler/core/parse.y -e "s;%pure-parser;%define api.pure;"
|
vsed -i mrbgems/mruby-compiler/core/parse.y -e "s;%pure-parser;%define api.pure;"
|
||||||
|
|
||||||
cat <<-EOF > xbps_config.rb
|
if [ -z "$CROSS_BUILD" ]; then
|
||||||
MRuby::Build.new do |conf|
|
# Native build
|
||||||
toolchain :gcc
|
cat <<-EOF > xbps_config.rb
|
||||||
conf.gem "#{root}/mrbgems/mruby-bin-mruby"
|
MRuby::Build.new do |conf|
|
||||||
conf.gem "#{root}/mrbgems/mruby-bin-mrbc"
|
toolchain :clang
|
||||||
conf.cc do |cc|
|
conf.gem "#{root}/mrbgems/mruby-bin-mruby"
|
||||||
cc.command = 'gcc'
|
conf.gem "#{root}/mrbgems/mruby-bin-mrbc"
|
||||||
cc.flags = [ENV['CFLAGS_host'] || %w()]
|
conf.cc do |cc|
|
||||||
cc.include_paths = ["#{root}/include"]
|
cc.command = 'clang'
|
||||||
end
|
cc.flags = [ENV['CFLAGS'] || %w()]
|
||||||
conf.linker do |linker|
|
cc.include_paths = ["#{root}/include"]
|
||||||
linker.command = 'gcc'
|
end
|
||||||
linker.libraries = 'm'
|
conf.linker do |linker|
|
||||||
end
|
linker.command = 'clang'
|
||||||
conf.archiver do |archiver|
|
linker.flags = [ENV['LDFLAGS'] || %w()]
|
||||||
archiver.command = 'ar'
|
linker.libraries = [ENV['LIBS'] || 'm']
|
||||||
end
|
end
|
||||||
end
|
conf.archiver do |archiver|
|
||||||
EOF
|
archiver.command = 'ar'
|
||||||
if [ "$CROSS_BUILD" ]; then
|
end
|
||||||
cat <<-EOF >> xbps_config.rb
|
end
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
# Cross build
|
||||||
|
cat <<-EOF > xbps_config.rb
|
||||||
|
MRuby::Build.new do |conf|
|
||||||
|
toolchain :clang
|
||||||
|
conf.gem "#{root}/mrbgems/mruby-bin-mruby"
|
||||||
|
conf.gem "#{root}/mrbgems/mruby-bin-mrbc"
|
||||||
|
conf.cc do |cc|
|
||||||
|
cc.command = 'clang'
|
||||||
|
cc.flags = [ENV['CFLAGS_host'] || %w()]
|
||||||
|
cc.include_paths = ["#{root}/include"]
|
||||||
|
end
|
||||||
|
conf.linker do |linker|
|
||||||
|
linker.command = 'clang'
|
||||||
|
linker.flags = [ENV['LDFLAGS_host'] || %w()]
|
||||||
|
linker.libraries = [ENV['LIBS'] || 'm']
|
||||||
|
end
|
||||||
|
conf.archiver do |archiver|
|
||||||
|
archiver.command = 'ar'
|
||||||
|
end
|
||||||
|
end
|
||||||
MRuby::CrossBuild.new('${XBPS_CROSS_TRIPLET}') do |conf|
|
MRuby::CrossBuild.new('${XBPS_CROSS_TRIPLET}') do |conf|
|
||||||
toolchain :gcc
|
toolchain :gcc
|
||||||
conf.gem "#{root}/mrbgems/mruby-bin-mruby"
|
conf.gem "#{root}/mrbgems/mruby-bin-mruby"
|
||||||
|
@ -54,8 +78,8 @@ do_configure() {
|
||||||
end
|
end
|
||||||
conf.linker do |linker|
|
conf.linker do |linker|
|
||||||
linker.command = ENV['CC'] || '${XBPS_CROSS_TRIPLET}-gcc'
|
linker.command = ENV['CC'] || '${XBPS_CROSS_TRIPLET}-gcc'
|
||||||
linker.libraries = ENV['LIBS'] || 'm'
|
linker.flags = [ENV['LDFLAGS'] || %w()]
|
||||||
linker.flags_after_libraries = [ENV['LDFLAGS'] || %w()]
|
linker.libraries = [ENV['LIBS'] || 'm']
|
||||||
linker.library_paths = '${XBPS_CROSS_BASE}/usr/lib'
|
linker.library_paths = '${XBPS_CROSS_BASE}/usr/lib'
|
||||||
end
|
end
|
||||||
conf.archiver do |archiver|
|
conf.archiver do |archiver|
|
||||||
|
@ -67,7 +91,28 @@ do_configure() {
|
||||||
}
|
}
|
||||||
|
|
||||||
do_build() {
|
do_build() {
|
||||||
MRUBY_CONFIG=xbps_config.rb ruby ./minirake
|
# Enable verbosity and/or trace
|
||||||
|
# vsed -i minirake -e '/^$rake_failed/a $verbose = 1'
|
||||||
|
# vsed -i minirake -e '/^$rake_failed/a $trace = 1'
|
||||||
|
|
||||||
|
# Set the number of parallel jobs from $makejobs
|
||||||
|
vsed -i minirake -e "s;^\(\$rake_jobs =\).*;\1 ${makejobs/-j/};"
|
||||||
|
|
||||||
|
# clang does not understand -fstack-clash-protection
|
||||||
|
CFLAGS="${CFLAGS/-fstack-clash-protection/}"
|
||||||
|
|
||||||
|
if [ "$CROSS_BUILD" ]; then
|
||||||
|
CFLAGS_host="${CFLAGS_host/-fstack-clash-protection/}"
|
||||||
|
echo "CFLAGS_host : $CFLAGS_host"
|
||||||
|
echo "LDFLAGS_host : $LDFLAGS_host"
|
||||||
|
fi
|
||||||
|
echo "CFLAGS : $CFLAGS"
|
||||||
|
echo "LDFLAGS : $LDFLAGS"
|
||||||
|
echo "LIBS : $LIBS"
|
||||||
|
CFLAGS="$CFLAGS" CFLAGS_host="$CFLAGS_host" \
|
||||||
|
LDFLAGS="$LDFLAGS" LDFLAGS_host="$LDFLAGS_host" \
|
||||||
|
LIBS="$LIBS" MRUBY_CONFIG=xbps_config.rb VERBOS=1 \
|
||||||
|
ruby minirake
|
||||||
}
|
}
|
||||||
|
|
||||||
do_install() {
|
do_install() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue