From b28b4459b0899cb8357df5f6c1e904fd1a34ebe3 Mon Sep 17 00:00:00 2001 From: Tiago Natel de Moura Date: Fri, 31 Jul 2020 12:21:21 +0100 Subject: Isolation: fixed the generation of mounts table. Since the introduction of rootfs feature, some language modules can't be configured multiple times. Now the configure generates a separate nxt__mounts.h for each module compiled. --- auto/modules/ruby | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'auto/modules/ruby') diff --git a/auto/modules/ruby b/auto/modules/ruby index f7334cc7..5cead26b 100644 --- a/auto/modules/ruby +++ b/auto/modules/ruby @@ -51,7 +51,6 @@ $echo "configuring Ruby module ..." >> $NXT_AUTOCONF_ERR NXT_RUBY=${NXT_RUBY=ruby} NXT_RUBY_MODULE=${NXT_RUBY_MODULE=${NXT_RUBY}} -NXT_RUBY_MOUNTS_HEADER=$NXT_BUILD_DIR/nxt_ruby_mounts.h nxt_found=no @@ -145,7 +144,10 @@ if grep ^$NXT_RUBY_MODULE: $NXT_MAKEFILE 2>&1 > /dev/null; then fi -cat << END > $NXT_RUBY_MOUNTS_HEADER +NXT_RUBY_MOUNTS_HEADER=nxt_${NXT_RUBY_MODULE}_mounts.h +NXT_RUBY_MOUNTS_PATH=$NXT_BUILD_DIR/$NXT_RUBY_MOUNTS_HEADER + +cat << END > $NXT_RUBY_MOUNTS_PATH static const nxt_fs_mount_t nxt_ruby_mounts[] = { {(u_char *) "$NXT_RUBY_RUBYHDRDIR", (u_char *) "$NXT_RUBY_RUBYHDRDIR", @@ -166,11 +168,11 @@ static const nxt_fs_mount_t nxt_ruby_mounts[] = { END for path in `echo $NXT_RUBY_GEMPATH | tr ':' '\n'`; do - $echo "{(u_char *) \"$path\", (u_char *) \"$path\"," >> $NXT_RUBY_MOUNTS_HEADER - $echo "(u_char *) \"bind\", NXT_MS_BIND | NXT_MS_REC, NULL}," >> $NXT_RUBY_MOUNTS_HEADER + $echo "{(u_char *) \"$path\", (u_char *) \"$path\"," >> $NXT_RUBY_MOUNTS_PATH + $echo "(u_char *) \"bind\", NXT_MS_BIND | NXT_MS_REC, NULL}," >> $NXT_RUBY_MOUNTS_PATH done -$echo "};" >> $NXT_RUBY_MOUNTS_HEADER +$echo "};" >> $NXT_RUBY_MOUNTS_PATH $echo " + Ruby module: ${NXT_RUBY_MODULE}.unit.so" @@ -200,7 +202,8 @@ for nxt_src in $NXT_RUBY_MODULE_SRCS; do $NXT_BUILD_DIR/$nxt_obj: $nxt_src $NXT_VERSION_H mkdir -p $NXT_BUILD_DIR/src/ruby - \$(CC) -c \$(CFLAGS) \$(NXT_INCS) $NXT_RUBY_INCPATH \\ + \$(CC) -c \$(CFLAGS) -DNXT_RUBY_MOUNTS_H=\"$NXT_RUBY_MOUNTS_HEADER\" \\ + \$(NXT_INCS) $NXT_RUBY_INCPATH \\ $nxt_dep_flags \\ -o $NXT_BUILD_DIR/$nxt_obj $nxt_src $nxt_dep_post -- cgit From 0d7a6885a32e01a1d6986f9b77a57f101cd3e8d9 Mon Sep 17 00:00:00 2001 From: Valentin Bartenev Date: Sat, 8 Aug 2020 23:52:31 +0300 Subject: Configure: verifying the Ruby library path. An attempt to build a Ruby module for a custom Ruby installation that has the same major version as the system Ruby may unexpectedly cause the use of the system Ruby library. This closes #449 issue on GitHub. --- auto/modules/ruby | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'auto/modules/ruby') diff --git a/auto/modules/ruby b/auto/modules/ruby index 5cead26b..f5384f98 100644 --- a/auto/modules/ruby +++ b/auto/modules/ruby @@ -70,25 +70,31 @@ if /bin/sh -c "$NXT_RUBY -v" >> $NXT_AUTOCONF_ERR 2>&1; then NXT_RUBY_LIBNAME=`$NXT_RUBY -r rbconfig -e 'printf("%s",RbConfig::CONFIG["RUBY_SO_NAME"])'` NXT_RUBY_LIBSCONF=`$NXT_RUBY -r rbconfig -e 'printf("%s",RbConfig::CONFIG["LIBS"])'` + NXT_RUBY_LIBPATH=`$NXT_RUBY -r rbconfig -e 'printf("%s",RbConfig::CONFIG["libdir"])'` NXT_RUBY_LIBS="-l$NXT_RUBY_LIBNAME $NXT_RUBY_LIBSCONF" nxt_feature="Ruby library" nxt_feature_name="" - nxt_feature_run=no + nxt_feature_run=value nxt_feature_incs="${NXT_RUBY_INCPATH}" nxt_feature_libs="${NXT_RUBY_LIBS}" nxt_feature_test=" #include int main() { + static const char *argv[3] = { + \"NGINX_Unit\", \"-rrbconfig\", + \"-eprint RbConfig::CONFIG['libdir']\" + }; + + RUBY_INIT_STACK; ruby_init(); - return ruby_cleanup(0); + return ruby_run_node(ruby_options(3, (char **) argv)); }" . auto/feature - if [ $nxt_found = no ]; then - NXT_RUBY_LIBPATH=`$NXT_RUBY -r rbconfig -e 'printf("%s",RbConfig::CONFIG["libdir"])'` + if [ "$nxt_feature_value" != "$NXT_RUBY_LIBPATH" ]; then NXT_RUBY_LIBS="-L$NXT_RUBY_LIBPATH -Wl,-rpath,${NXT_RUBY_LIBPATH} $NXT_RUBY_LIBS" nxt_feature="Ruby library in $NXT_RUBY_LIBPATH" -- cgit From 7e1d800f08f365dd3be7cd614d0fac01ca16ad28 Mon Sep 17 00:00:00 2001 From: Valentin Bartenev Date: Sun, 9 Aug 2020 01:00:44 +0300 Subject: Ruby: removed unused variable from ./configure script. --- auto/modules/ruby | 1 - 1 file changed, 1 deletion(-) (limited to 'auto/modules/ruby') diff --git a/auto/modules/ruby b/auto/modules/ruby index f5384f98..7c3f8328 100644 --- a/auto/modules/ruby +++ b/auto/modules/ruby @@ -58,7 +58,6 @@ if /bin/sh -c "$NXT_RUBY -v" >> $NXT_AUTOCONF_ERR 2>&1; then NXT_RUBY_RUBYHDRDIR=`$NXT_RUBY -r rbconfig -e 'printf("%s",RbConfig::CONFIG["rubyhdrdir"])'` NXT_RUBY_ARCHHDRDIR=`$NXT_RUBY -r rbconfig -e 'printf("%s",RbConfig::CONFIG["rubyarchhdrdir"])'` - NXT_RUBY_SITEARCHDIR=`$NXT_RUBY -r rbconfig -e 'printf("%s",RbConfig::CONFIG["sitearchhdrdir"])'` NXT_RUBY_SITEDIR=`$NXT_RUBY -r rbconfig -e 'printf("%s",RbConfig::CONFIG["sitedir"])'` NXT_RUBY_LIBDIR=`$NXT_RUBY -r rbconfig -e 'printf("%s",RbConfig::CONFIG["rubylibdir"])'` NXT_RUBY_TOPDIR=`$NXT_RUBY -r rbconfig -e 'printf("%s",RbConfig::CONFIG["topdir"])'` -- cgit From 317fabc83e7ef7c423a64388de67ea851115b1b9 Mon Sep 17 00:00:00 2001 From: Valentin Bartenev Date: Sun, 9 Aug 2020 01:00:44 +0300 Subject: Ruby: simplified commands in ./configure script. There is no reason to use printf instead of just print. No functional changes. --- auto/modules/ruby | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'auto/modules/ruby') diff --git a/auto/modules/ruby b/auto/modules/ruby index 7c3f8328..bf628935 100644 --- a/auto/modules/ruby +++ b/auto/modules/ruby @@ -56,20 +56,20 @@ nxt_found=no if /bin/sh -c "$NXT_RUBY -v" >> $NXT_AUTOCONF_ERR 2>&1; then - NXT_RUBY_RUBYHDRDIR=`$NXT_RUBY -r rbconfig -e 'printf("%s",RbConfig::CONFIG["rubyhdrdir"])'` - NXT_RUBY_ARCHHDRDIR=`$NXT_RUBY -r rbconfig -e 'printf("%s",RbConfig::CONFIG["rubyarchhdrdir"])'` - NXT_RUBY_SITEDIR=`$NXT_RUBY -r rbconfig -e 'printf("%s",RbConfig::CONFIG["sitedir"])'` - NXT_RUBY_LIBDIR=`$NXT_RUBY -r rbconfig -e 'printf("%s",RbConfig::CONFIG["rubylibdir"])'` - NXT_RUBY_TOPDIR=`$NXT_RUBY -r rbconfig -e 'printf("%s",RbConfig::CONFIG["topdir"])'` - NXT_RUBY_PREFIXDIR=`$NXT_RUBY -r rbconfig -e 'printf("%s",RbConfig::CONFIG["rubylibprefix"])'` + NXT_RUBY_RUBYHDRDIR=`$NXT_RUBY -rrbconfig -e 'print RbConfig::CONFIG["rubyhdrdir"]'` + NXT_RUBY_ARCHHDRDIR=`$NXT_RUBY -rrbconfig -e 'print RbConfig::CONFIG["rubyarchhdrdir"]'` + NXT_RUBY_SITEDIR=`$NXT_RUBY -rrbconfig -e 'print RbConfig::CONFIG["sitedir"]'` + NXT_RUBY_LIBDIR=`$NXT_RUBY -rrbconfig -e 'print RbConfig::CONFIG["rubylibdir"]'` + NXT_RUBY_TOPDIR=`$NXT_RUBY -rrbconfig -e 'print RbConfig::CONFIG["topdir"]'` + NXT_RUBY_PREFIXDIR=`$NXT_RUBY -rrbconfig -e 'print RbConfig::CONFIG["rubylibprefix"]'` NXT_RUBY_GEMDIR=`gem environment gemdir` NXT_RUBY_GEMPATH=`gem environment gempath` NXT_RUBY_INCPATH="-I$NXT_RUBY_ARCHHDRDIR -I$NXT_RUBY_RUBYHDRDIR" - NXT_RUBY_LIBNAME=`$NXT_RUBY -r rbconfig -e 'printf("%s",RbConfig::CONFIG["RUBY_SO_NAME"])'` - NXT_RUBY_LIBSCONF=`$NXT_RUBY -r rbconfig -e 'printf("%s",RbConfig::CONFIG["LIBS"])'` - NXT_RUBY_LIBPATH=`$NXT_RUBY -r rbconfig -e 'printf("%s",RbConfig::CONFIG["libdir"])'` + NXT_RUBY_LIBNAME=`$NXT_RUBY -rrbconfig -e 'print RbConfig::CONFIG["RUBY_SO_NAME"]'` + NXT_RUBY_LIBSCONF=`$NXT_RUBY -rrbconfig -e 'print RbConfig::CONFIG["LIBS"]'` + NXT_RUBY_LIBPATH=`$NXT_RUBY -rrbconfig -e 'print RbConfig::CONFIG["libdir"]'` NXT_RUBY_LIBS="-l$NXT_RUBY_LIBNAME $NXT_RUBY_LIBSCONF" nxt_feature="Ruby library" -- cgit From 91280b4c0b3ec0721a8f3ba09a1cc9f5ca56c238 Mon Sep 17 00:00:00 2001 From: Valentin Bartenev Date: Sun, 9 Aug 2020 01:00:44 +0300 Subject: Ruby: fixed gem mount paths. The gem paths must depend on the specified interpreter. Also, gemdir looks redundant as it's already included in Gem.default_path(). --- auto/modules/ruby | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'auto/modules/ruby') diff --git a/auto/modules/ruby b/auto/modules/ruby index bf628935..c1444f07 100644 --- a/auto/modules/ruby +++ b/auto/modules/ruby @@ -62,8 +62,8 @@ if /bin/sh -c "$NXT_RUBY -v" >> $NXT_AUTOCONF_ERR 2>&1; then NXT_RUBY_LIBDIR=`$NXT_RUBY -rrbconfig -e 'print RbConfig::CONFIG["rubylibdir"]'` NXT_RUBY_TOPDIR=`$NXT_RUBY -rrbconfig -e 'print RbConfig::CONFIG["topdir"]'` NXT_RUBY_PREFIXDIR=`$NXT_RUBY -rrbconfig -e 'print RbConfig::CONFIG["rubylibprefix"]'` - NXT_RUBY_GEMDIR=`gem environment gemdir` - NXT_RUBY_GEMPATH=`gem environment gempath` + + NXT_RUBY_GEMPATH=`$NXT_RUBY -rrubygems -e 'print Gem.default_path().join(":")'` NXT_RUBY_INCPATH="-I$NXT_RUBY_ARCHHDRDIR -I$NXT_RUBY_RUBYHDRDIR" @@ -163,8 +163,6 @@ static const nxt_fs_mount_t nxt_ruby_mounts[] = { (u_char *) "bind", NXT_MS_BIND | NXT_MS_REC, NULL}, {(u_char *) "$NXT_RUBY_LIBDIR", (u_char *) "$NXT_RUBY_LIBDIR", (u_char *) "bind", NXT_MS_BIND | NXT_MS_REC, NULL}, - {(u_char *) "$NXT_RUBY_GEMDIR", (u_char *) "$NXT_RUBY_GEMDIR", - (u_char *) "bind", NXT_MS_BIND | NXT_MS_REC, NULL}, {(u_char *) "$NXT_RUBY_TOPDIR", (u_char *) "$NXT_RUBY_TOPDIR", (u_char *) "bind", NXT_MS_BIND | NXT_MS_REC, NULL}, {(u_char *) "$NXT_RUBY_PREFIXDIR", (u_char *) "$NXT_RUBY_PREFIXDIR", -- cgit