Граф коммитов

183 Коммитов

Автор SHA1 Сообщение Дата
Peter Zhu 25ad9eabc7 Only define RUBY_DLN_CHECK_ABI when supported 2022-03-01 09:44:39 -05:00
Peter Zhu 210f29a6bf ABI checking is not supported on Windows 2022-03-01 09:42:32 -05:00
Yuta Saito 33dadb2c8a dln.c: suppress unused function 'abi_check_enabled_p' warning for wasi 2022-03-01 23:33:48 +09:00
Peter Zhu 3df16924b4 [Feature #18249] Implement ABI checking
Header file include/ruby/internal/abi.h contains RUBY_ABI_VERSION which
is the ABI version. This value should be bumped whenever an ABI
incompatible change is introduced.

When loading dynamic libraries, Ruby will compare its own
`ruby_abi_version` and the `ruby_abi_version` of the loaded library. If
these two values don't match it will raise a `LoadError`. This feature
can also be turned off by setting the environment variable
`RUBY_RUBY_ABI_CHECK=0`.

This feature will prevent cases where previously installed native gems
fail in unexpected ways due to incompatibility of changes in header
files. This will force the developer to recompile their gems to use the
same header files as the built Ruby.

In Ruby, the ABI version is exposed through
`RbConfig::CONFIG["ruby_abi_version"]`.
2022-02-22 09:55:21 -05:00
Peter Zhu 82513c7d71 Remove unused function declaration in dln.c
getenv is no longer used in dln.c.
2022-02-18 09:30:08 -05:00
Nobuyoshi Nakada 992bdfea2d
Refine the load error message
Show the linked ruby library name when failed to load extension
built against different ruby library.
2022-02-17 20:29:50 +09:00
Nobuyoshi Nakada 5952a1f201
Check running macOS version at runtime 2022-02-17 20:29:50 +09:00
Kazuhiro NISHIYAMA eba90bc034
Fix warnings
```
compiling ..../ruby/ruby/dln.c
..../ruby/ruby/dln.c:108:1: warning: unused function 'init_funcname_len' [-Wunused-function]
init_funcname_len(const char **file)
^
..../ruby/ruby/dln.c:122:19: warning: unused variable 'funcname_prefix' [-Wunused-const-variable]
static const char funcname_prefix[sizeof(FUNCNAME_PREFIX) - 1] = FUNCNAME_PREFIX;
		  ^
2 warnings generated.
```
2022-01-20 10:03:59 +09:00
Peter Zhu 5c4734d1ef Refactor dln_load into dln_open and dln_sym
Refactor dln_load into dln_open and dln_sym to simplify the code for
Windows and platforms that have dlopen.
2022-01-19 09:55:09 -05:00
Peter Zhu ffda21b7ba [Feature #18491] Drop support for HP-UX
IA64 support was dropped in ticket #15894, so we can drop support for
HP-UX.
2022-01-18 09:52:15 -05:00
Peter Zhu 3cc82ff93c Drop support for OSX 10.3 and earlier
dlopen was introduced in OSX 10.4, which was released in 2005. OSX 10.3
was EOL in 2007.
2022-01-14 11:29:08 -05:00
Nobuyoshi Nakada 06bdb41c45
dln.c: refine preprocessor conditions by USE_DLN_DLOPEN and _WIN32 2021-12-17 00:44:54 +09:00
卜部昌平 de2afff1b9 dln.c: add missing dependency 2021-09-10 20:00:06 +09:00
Nobuyoshi Nakada 0bbab1e515
Protoized old pre-ANSI K&R style declarations and definitions 2021-05-07 00:04:36 +09:00
Nobuyoshi Nakada 1f08b0d18d
Removed dln_a_out
a.out format is considered extinct nowadays.
2021-03-24 20:13:55 +09:00
Nobuyoshi Nakada c9d0053e67
Fixed compilation errors when USE_DLN_A_OUT 2021-03-24 13:23:55 +09:00
卜部昌平 9e41a75255 sed -i 's|ruby/impl|ruby/internal|'
To fix build failures.
2020-05-11 09:24:08 +09:00
卜部昌平 d7f4d732c1 sed -i s|ruby/3|ruby/impl|g
This shall fix compile errors.
2020-05-11 09:24:08 +09:00
卜部昌平 9e6e39c351
Merge pull request #2991 from shyouhei/ruby.h
Split ruby.h
2020-04-08 13:28:13 +09:00
卜部昌平 115fec062c more on NULL versus functions.
Function pointers are not void*.  See also
ce4ea956d2
8427fca49b
2020-02-07 14:24:19 +09:00
卜部昌平 5e22f873ed decouple internal.h headers
Saves comitters' daily life by avoid #include-ing everything from
internal.h to make each file do so instead.  This would significantly
speed up incremental builds.

We take the following inclusion order in this changeset:

1.  "ruby/config.h", where _GNU_SOURCE is defined (must be the very
    first thing among everything).
2.  RUBY_EXTCONF_H if any.
3.  Standard C headers, sorted alphabetically.
4.  Other system headers, maybe guarded by #ifdef
5.  Everything else, sorted alphabetically.

Exceptions are those win32-related headers, which tend not be self-
containing (headers have inclusion order dependencies).
2019-12-26 20:45:12 +09:00
Samuel Williams d17344cfc5 Remove IA64 support. 2019-06-19 23:30:04 +12:00
shyouhei d83536c980 reduce copy & paste
We see several occurrence of "diagnostic push/pop" so why not
make them macros.  Tested on GCC8 / Clang 6.

Note that ruby.h is intentionally left untouched because we don't
want to introduce new public macros.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-30 07:07:48 +00:00
nobu c434b4aba7 constified
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 00:06:00 +00:00
nobu 44cf5baa62 dln.c: dln_incompatible_library_p
* dln.c (dln_incompatible_library_p): renamed as the error message
  with dln prefix, since it is not bound to xmalloc restrictively.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-03 09:19:11 +00:00
nobu 21a2146e1d dln.c: xmalloc_mismatch_p with dlopen
* dln.c (xmalloc_mismatch_p): define only when using dlopen,
  otherwise dlsym is not available too, and should be used then.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-03 09:05:18 +00:00
shyouhei 6faadd7838 include missing header
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-02 06:46:40 +00:00
shyouhei 8dc0c7c035 comparing function pointer versus void* is a GCCism
However dlsym() requires such feature so this function is non-
portable by nature.  Cannot but suppress warning.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61559 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-02 06:41:55 +00:00
nobu 79c50a77ff get rid of strcpy
* addr2line.c (follow_debuglink): insert global_debug_dir by using
  memmove instead of copying to temporary buffer.

* dln.c (dln_load): use memcpy with the known length instead of
  strcpy.

* gc.c (rb_gc_unprotect_logging): use strdup instead of malloc and
  strcpy.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-26 09:28:46 +00:00
nobu 5908268c14 dln.c: raise LoadError
* dln.c (dln_load): raise LoadError instead of fatal error on
  recent OSX, dlclose seems fixed in El Capitan or later.
  [ruby-core:78200] [Bug #12956]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-19 01:16:50 +00:00
nobu 139579b501 dln.c: move error message definition
* dln.c (dln_load): move the definition of incompatible library
  version error message to be shared.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-07 23:46:45 +00:00
nobu 13a935b0ba Drop support for BeOS
* beos: Drop support for BeOS now that Haiku is stable.
  [Fix GH-1112]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-24 00:17:11 +00:00
nobu e29c109d2a Haiku now best effort support
* configure.in: remove obsolete workarounds for Haiku.
* dln.c, file.c, io.c: remove obsolete Haiku workarounds.
* thread_pthread.c: add stack bounds detection for Haiku.
* signal.c: get stack pointer from signal context on Haiku.
  [ruby-core:67923] [Bug #10811] [Fix GH-1109]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-23 03:54:42 +00:00
kosaki 348d7b096d * dln.c: remove defined(__WATCOMC__).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-18 02:23:18 +00:00
kosaki 3a48e12607 * numeric.c: Good-by Borland-C.
* include/ruby/backward/rubyio.h: ditto.
* include/ruby/backward/st.h: ditto.
* include/ruby/backward/util.h: ditto.
* include/ruby/backward/rubysig.h: ditto.
* include/ruby/backward/classext.h: ditto.
* dln.c: ditto.
* gc.c: ditto.
* win32/resource.rb: ditto.
* win32/dir.h: ditto.
* ext/tk/tcltklib.c: ditto.
* NEWS: announce that Borland-C is no longer supported.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-18 02:10:34 +00:00
kosaki e91baf5634 * dln.c: simplify #ifdef. _WIN32 and __CYGWIN__ are exclusive.
see include/ruby/defines.h
* gc.c: ditto.
* ext/sdbm/_sdbm.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-18 02:08:56 +00:00
nobu 75319221a2 dln.c: fix EXTERNAL_PREFIX
* configure.in (EXPORT_PREFIX): revert r50410.

* dln.c (EXTERNAL_PREFIX): define by predefined macros.
  configured EXPORT_PREFIX is different thing.

* win32/Makefile.sub: r50414-50415.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-01 07:27:03 +00:00
nobu 55851c982d dln.c: raise fatal
* dln.c (dln_load): raise fatal error on OSX not other extension
  libraries to refer different libruby.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-01 04:41:27 +00:00
nobu f2604ef512 dln.c: check incompatible libruby
* dln.c (dln_load): check if a different libruby is loaded by the
  extension library, and then bail out to get rid of very frequent
  reported stale bug reports.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-01 04:30:26 +00:00
nobu 70abda7e44 dln.c: use EXPORT_PREFIX
* configure.in (EXPORT_PREFIX): define exported symbol prefix
  string in config.h.

* dln.c (FUNCNAME_PREFIX): use configured EXPORT_PREFIX, not
  hardcoded condition.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-01 04:29:20 +00:00
yugui 69ac654c90 Merges a patch form naclports.
* configure.in (RUBY_NACL and others): Supports PNaCl.
* dln.c: replace the old hacky dynamic loading over HTTP with nacl_io.
* file.c: tenatively use access(2) instead of eaccess.
  (rb_file_load_ok): weaken with attribute but not by postprocess.
* io.c (socket.h): now NaCl has socket.h
  (flock): disable here instead of nacl/ioctl.h
* nacl/GNUmakefile.in (CC, LD, NM, AR, AS, RANLIB, OBJDUMP, OBJCOPY):
  respect path to them if they are absolute.
  This helps naclports to build ruby in their source tree.
  (PROGRAM_NMF, .SUFFIXES): support .pnexe for PNaCl.
  (ruby.o, file.o): move the hack to attributes in ruby.c and file.c
* nacl/ioctl.h: removed. move the hack to io.c.
* nacl/nacl-config.rb: support arm, pnacl and others.
* nacl/pepper_main.c: support build in a naclports tree.
* ruby.c (rb_load_file): weaken with attribute but not by postprocess.

The patch is by sbc@google.com and the Native Client Authors.
It is available at:
* 873ca4910a/ports/ruby/nacl.patch

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-11 02:11:53 +00:00
hsbt 8362f9b581 * symbian/*: removed Symbian support.
[Feature #10199][ruby-core:64725]
* dln.c: ditto.
* include/ruby/defines.h: ditto.
* thread_pthread.c: ditto.
* vm.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-04 11:09:32 +00:00
nobu 6ab08d2e8d configure.in, missing.h: jemalloc mangling
* configure.in (with-jemalloc): also check for header, for ABIs
  which JEMALLOC_MANGLE is needed, i.e., Mach-O and PE-COFF
  platforms.  [ruby-core:62939] [Feature #9113]
* include/ruby/missing.h: include alternative malloc header to
  replace memory management functions.
* dln.c, io.c, parse.y, st.c: undef malloc family before
  re-definition to suppress warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-05 05:16:46 +00:00
nobu a237db5cbc dln.c: non-ascii path on Windows
* dln.c (dln_load): use wchar version to load a library in
  non-ascii path on Windows.  based on the patch by Bugra Barin
  <bugrabarin AT hotmail.com> in [ruby-core:61845].  [Bug #9699]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-05 23:52:52 +00:00
nobu cc216f9aae adjust indent and style
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-27 07:10:14 +00:00
nobu 057098bfdc use strlcat
* addr2line.c (follow_debuglink): use strlcat instead of strncat.

* dln.c (aix_loaderror): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-27 07:10:13 +00:00
nobu 66fd9d44d8 adjust style.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-01 15:25:28 +00:00
kosaki 3e1d8aab17 * dln.c: Simplify and make consistent an ifdef for Mac OS X.
* ext/socket/rubysocket.h: ditto.
* ext/tk/stubs.c: ditto.
* io.c: ditto.
* process.c: ditto.
* signal.c: ditto.
* vm_dump.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-09 15:52:49 +00:00
yugui 76bc2d1ed7 Imports Ruby's port to NativeClient (a.k.a NaCl).
Patch by Google Inc. [ruby-core:45073].

* configure.in (RUBY_NACL): New M4 func to configure variables for
  NaCl.
  (RUBY_NACL_CHECK_PEPPER_TYPES): New M4 func to check the old names
  of Pepper interface types.
  (BTESTRUBY): New variable to specify which ruby should be run on
  "make btest". NaCl can run the built binary by sel_ldr, but it need
  rbconfig.rb. So this variable is distinguished from $MINIRUBY.
  
* thread_pthread.c: Disabled some features on NaCl.

* io.c: ditto.

* process.c: ditto.

* signal.c: ditto.

* file.c: ditto.

* missing/flock.c: ditto.

* nacl/pepper_main.c: An example implementation of Pepper application
  that embeds Ruby.

* nacl/example.html: An example of web page that uses the Pepper
  application.

* nacl/nacl-config.rb: Detects variants of NaCl SDK.

* nacl/GNUmakefile.in: Makefile template for NaCl specific build
  process.

* nacl/package.rb: script for packaging a NaCl-Ruby embedding
  application. 

* nacl/reate_nmf.rb: Wrapper script of create_nmf.py

* dln.c (dln_load): Added a hack to call on NaCl.

* util.c (ruby_getcwd): Path to the current directort is not available
  on NaCl.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-17 02:48:59 +00:00
nobu dad31f6e50 * dln.c (rb_w32_check_imported): skip ordinal entries. based on a
patch by phasis68 (Heesob Park) at [ruby-core:44381].
  [ruby-core:44371][Bug #6303]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-17 04:11:17 +00:00