Improve build process and coroutine implementation selection.

This commit is contained in:
Samuel Williams 2019-06-29 13:07:07 +12:00
parent 91aae651bf
commit 7291fef55c
No known key found for this signature in database
GPG Key ID: A0765423A44728FB
5 changed files with 50 additions and 47 deletions

View File

@ -924,9 +924,8 @@ strlcpy.$(OBJEXT): {$(VPATH)}strlcpy.c
strstr.$(OBJEXT): {$(VPATH)}strstr.c strstr.$(OBJEXT): {$(VPATH)}strstr.c
nt.$(OBJEXT): {$(VPATH)}nt.c nt.$(OBJEXT): {$(VPATH)}nt.c
COROUTINE_SRC = $(COROUTINE_H:.h=).$(ASMEXT)
.coroutine_obj $(COROUTINE_OBJ): \ .coroutine_obj $(COROUTINE_OBJ): \
{$(VPATH)}$(COROUTINE_SRC:/ucontext/Context.S=/ucontext/Context.c) \ {$(VPATH)}$(COROUTINE_SRC) \
$(COROUTINE_H:/Context.h=/.time) $(COROUTINE_H:/Context.h=/.time)
$(COROUTINE_H:/Context.h=/.time): $(COROUTINE_H:/Context.h=/.time):
$(Q) $(MAKEDIRS) $(@D) $(Q) $(MAKEDIRS) $(@D)

View File

@ -964,7 +964,7 @@ main()
AS_IF([test "$target_cpu" = x64], [ AS_IF([test "$target_cpu" = x64], [
ac_cv_func___builtin_setjmp=yes ac_cv_func___builtin_setjmp=yes
ac_cv_func_round=no ac_cv_func_round=no
rb_cv_fiber_coroutine=yes rb_cv_coroutine=yes
]) ])
ac_cv_func_tgamma=no ac_cv_func_tgamma=no
rb_cv_negative_time_t=yes rb_cv_negative_time_t=yes
@ -2251,60 +2251,67 @@ AS_IF([test "${universal_binary-no}" = yes ], [
AC_DEFINE_UNQUOTED(STACK_GROW_DIRECTION, $dir) AC_DEFINE_UNQUOTED(STACK_GROW_DIRECTION, $dir)
]) ])
AC_ARG_ENABLE(fiber-coroutine, AC_ARG_WITH(coroutine,
AS_HELP_STRING([--disable-fiber-coroutine], [disable native coroutine implementation for fiber]), AS_HELP_STRING([--with-coroutine=IMPLEMENTATION], [specify the coroutine implementation to use]),
[rb_cv_fiber_coroutine=$enableval]) [rb_cv_coroutine=$withval])
AS_CASE(["$rb_cv_fiber_coroutine"], [yes|''], [ AS_CASE([$rb_cv_coroutine], [yes|''], [
AC_MSG_CHECKING(native coroutine implementation for ${target_cpu}-${target_os}) AC_MSG_CHECKING(native coroutine implementation for ${target_cpu}-${target_os})
AS_CASE(["$target_cpu-$target_os"], AS_CASE(["$target_cpu-$target_os"],
[x*64-darwin*], [ [x*64-darwin*], [
rb_cv_fiber_coroutine=amd64 rb_cv_coroutine=amd64
], ],
[x*64-linux], [ [x*64-linux], [
AS_CASE(["$ac_cv_sizeof_voidp"], AS_CASE(["$ac_cv_sizeof_voidp"],
[8], [ rb_cv_fiber_coroutine=amd64 ], [8], [ rb_cv_coroutine=amd64 ],
[4], [ rb_cv_fiber_coroutine=x86 ], [4], [ rb_cv_coroutine=x86 ],
[*], [ rb_cv_fiber_coroutine= ] [*], [ rb_cv_coroutine= ]
) )
], ],
[*86-linux], [ [*86-linux], [
rb_cv_fiber_coroutine=x86 rb_cv_coroutine=x86
], ],
[x64-mingw32], [ [x64-mingw32], [
rb_cv_fiber_coroutine=win64 rb_cv_coroutine=win64
], ],
[*86-mingw32], [ [*86-mingw32], [
rb_cv_fiber_coroutine=win32 rb_cv_coroutine=win32
], ],
[armv7*-linux-*], [ [armv7*-linux-*], [
rb_cv_fiber_coroutine=ucontext rb_cv_coroutine=ucontext
], ],
[aarch64-linux], [ [aarch64-linux], [
rb_cv_fiber_coroutine=arm64 rb_cv_coroutine=arm64
], ],
[powerpc64le-linux], [ [powerpc64le-linux], [
rb_cv_fiber_coroutine=ppc64le rb_cv_coroutine=ppc64le
], ],
[x86_64-openbsd*], [ [x86_64-openbsd*], [
rb_cv_fiber_coroutine=amd64 rb_cv_coroutine=amd64
], ],
[i386-openbsd*], [ [i386-openbsd*], [
rb_cv_fiber_coroutine=x86 rb_cv_coroutine=x86
], ],
[*-openbsd*], [ [*-openbsd*], [
rb_cv_fiber_coroutine= rb_cv_coroutine=copy
], ],
[*], [ [*], [
rb_cv_fiber_coroutine=ucontext rb_cv_coroutine=ucontext
] ]
) )
AC_MSG_RESULT(${rb_cv_fiber_coroutine:-no}) AC_MSG_RESULT(${rb_cv_coroutine})
])
AS_IF([test "${rb_cv_fiber_coroutine:-no}" != no], [
COROUTINE_H=coroutine/$rb_cv_fiber_coroutine/Context.h
AC_DEFINE_UNQUOTED(FIBER_USE_COROUTINE, ["$COROUTINE_H"])
AC_SUBST(X_FIBER_COROUTINE_H, [$COROUTINE_H])
]) ])
COROUTINE_H=coroutine/$rb_cv_coroutine/Context.h
AS_CASE([$rb_cv_coroutine],
[copy|ucontext], [
COROUTINE_SRC=coroutine/$rb_cv_coroutine/Context.c
],
[*], [
COROUTINE_SRC=coroutine/$rb_cv_coroutine/Context.'$(ASMEXT)'
],
)
AC_DEFINE_UNQUOTED(COROUTINE_H, ["$COROUTINE_H"])
AC_SUBST(X_COROUTINE_H, [$COROUTINE_H])
AC_SUBST(X_COROUTINE_SRC, [$COROUTINE_SRC])
AS_IF([test x"$enable_pthread" = xyes], [ AS_IF([test x"$enable_pthread" = xyes], [
for pthread_lib in thr pthread pthreads c c_r root; do for pthread_lib in thr pthread pthreads c c_r root; do
@ -4009,6 +4016,7 @@ config_summary "vendor path" "$vendordir"
config_summary "target OS" "$target_os" config_summary "target OS" "$target_os"
config_summary "compiler" "$CC" config_summary "compiler" "$CC"
config_summary "with pthread" "$enable_pthread" config_summary "with pthread" "$enable_pthread"
config_summary "with coroutine" "$rb_cv_coroutine"
config_summary "enable shared libs" "$ENABLE_SHARED" config_summary "enable shared libs" "$ENABLE_SHARED"
config_summary "dynamic library ext" "$DLEXT" config_summary "dynamic library ext" "$DLEXT"
config_summary "CFLAGS" "$cflags" config_summary "CFLAGS" "$cflags"

7
cont.c
View File

@ -15,12 +15,7 @@
#include "eval_intern.h" #include "eval_intern.h"
#include "mjit.h" #include "mjit.h"
#ifdef FIBER_USE_COROUTINE #include COROUTINE_H
#include FIBER_USE_COROUTINE
#else
// Stack copying implementation, should work everywhere:
#include "coroutine/copy/Context.h"
#endif
#ifndef _WIN32 #ifndef _WIN32
#include <unistd.h> #include <unistd.h>

View File

@ -152,8 +152,9 @@ XRUBY_RUBYLIBDIR = @XRUBY_RUBYLIBDIR@
XRUBY_RUBYHDRDIR = @XRUBY_RUBYHDRDIR@ XRUBY_RUBYHDRDIR = @XRUBY_RUBYHDRDIR@
BOOTSTRAPRUBY = @BOOTSTRAPRUBY@ BOOTSTRAPRUBY = @BOOTSTRAPRUBY@
COROUTINE_H = @X_FIBER_COROUTINE_H@ COROUTINE_H = @X_COROUTINE_H@
COROUTINE_OBJ = $(COROUTINE_H:.h=.@OBJEXT@) COROUTINE_OBJ = $(COROUTINE_H:.h=.@OBJEXT@)
COROUTINE_SRC = @X_COROUTINE_SRC@
#### End of system configuration section. #### #### End of system configuration section. ####

View File

@ -290,19 +290,18 @@ MISSING = $(MISSING) acosh.obj cbrt.obj erf.obj nan.obj tgamma.obj
MISSING = $(MISSING) explicit_bzero.obj MISSING = $(MISSING) explicit_bzero.obj
!endif !endif
DLNOBJ = dln.obj DLNOBJ = dln.obj
!if "$(ARCH)" == "x64" !if "$(ARCH)" == "x64"
COROUTINE_OBJ = coroutine/Win64/Context.obj COROUTINE_OBJ = coroutine/win64/Context.obj
COROUTINE_SRC = $(COROUTINE_OBJ:.obj=.asm)
!elseif "$(ARCH)" == "i386" !elseif "$(ARCH)" == "i386"
COROUTINE_OBJ = coroutine/Win32/Context.obj COROUTINE_OBJ = coroutine/win32/Context.obj
COROUTINE_SRC = $(COROUTINE_OBJ:.obj=.asm)
!else !else
COROUTINE_OBJ = COROUTINE_OBJ = coroutine/copy/Context.obj
COROUTINE_SRC = $(COROUTINE_OBJ:.obj=.c)
!endif !endif
!if "$(COROUTINE_OBJ)" == ""
# get rid of empty value not to leave VPATH only in dependencies
COROUTINE_H = coroutine/Win32/Context.h
!else
COROUTINE_H = $(COROUTINE_OBJ:.obj=.h) COROUTINE_H = $(COROUTINE_OBJ:.obj=.h)
!endif
ARFLAGS = -machine:$(MACHINE) -out: ARFLAGS = -machine:$(MACHINE) -out:
LD = $(CC) LD = $(CC)
@ -871,9 +870,7 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub
!if "$(MACHINE)" == "x86" || "$(ARCH)" == "x64" !if "$(MACHINE)" == "x86" || "$(ARCH)" == "x64"
#define STACK_GROW_DIRECTION -1 #define STACK_GROW_DIRECTION -1
!endif !endif
!if "$(COROUTINE_OBJ)" != "" #define COROUTINE_H "$(COROUTINE_H)"
#define FIBER_USE_COROUTINE "$(COROUTINE_H)"
!endif
#define DEFAULT_KCODE KCODE_NONE #define DEFAULT_KCODE KCODE_NONE
#define LOAD_RELATIVE 1 #define LOAD_RELATIVE 1
#define DLEXT ".so" #define DLEXT ".so"
@ -1235,12 +1232,15 @@ $(ruby_pc): $(RBCONFIG)
-output=$@ -mode=$(INSTALL_DATA_MODE) -config=rbconfig.rb \ -output=$@ -mode=$(INSTALL_DATA_MODE) -config=rbconfig.rb \
$(srcdir)/template/ruby.pc.in $(srcdir)/template/ruby.pc.in
{$(srcdir)/coroutine/Win32}.asm{coroutine/Win32}.obj: {$(srcdir)/coroutine/win32}.asm{coroutine/win32}.obj:
$(ECHO) assembling $(<:\=/) $(ECHO) assembling $(<:\=/)
$(Q) $(AS) $(ASFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $(<:\=/) $(Q) $(AS) $(ASFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $(<:\=/)
{$(srcdir)/coroutine/Win64}.asm{coroutine/Win64}.obj: {$(srcdir)/coroutine/win64}.asm{coroutine/win64}.obj:
$(ECHO) assembling $(<:\=/) $(ECHO) assembling $(<:\=/)
$(Q) $(AS) $(ASFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $(<:\=/) $(Q) $(AS) $(ASFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $(<:\=/)
{$(srcdir)/coroutine/copy}.c{coroutine/copy}.obj:
$(ECHO) compiling $(<:\=/)
$(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$(<:\=/)
{$(srcdir)/enc/trans}.c.obj: {$(srcdir)/enc/trans}.c.obj:
$(ECHO) compiling $(<:\=/) $(ECHO) compiling $(<:\=/)