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

194 Коммитов

Автор SHA1 Сообщение Дата
Yuta Saito 36b389c206 [wasm] dln.c: Guard `dladdr` use in symbol incompatibility check
wasi-libc recently added a family of `dl*` functions[^1], but it still
doesn't have `dladdr` unlike other platforms. Guard the use of `dladdr`
with `HAVE_DLADDR` to avoid build failure with the head version of
wasi-libc.
The library name is used only for diagnostic purpose if it's not NULL,
so it's safe to skip it.

[^1]: b85d65528d
2023-12-19 11:13:38 +09:00
Satoshi Tagomori e51f9e9f75 rb_ext_resolve_symbol: C API to resolve and return externed symbols [Feature #20005]
This is a C API for extensions to resolve and get function symbols of other extensions.
Extensions can check the expected symbol is correctly loaded and accessible, and
use it if it is available.
Otherwise, extensions can raise their own error to guide users to setup their
environments correctly and what's missing.
2023-12-14 17:39:42 +09:00
Satoshi Tagomori 8a37df8c8b dln_symbol: make dln_sym accessible Ruby internally
The symbol resolved by dln_symbol will eventually be passed to
extensions. The error handling of dln_sym is also separated into
dln_sym_func because the new call resolving symbols will not raise
LoadError.
2023-12-14 17:39:42 +09:00
Nobuyoshi Nakada 371a3a691f Add EXTERNAL_PREFIX to ruby_abi_version 2023-11-21 17:21:26 +09:00
Nobuyoshi Nakada 029871c3fe typedef ABI version types 2023-11-21 17:21:26 +09:00
drew-wells 9aaf2b7526
Update dln.c to fix error output from `dln_open()`
`libruby_name` gets trashed by `dlclose(handle)`, so output the
"linked to incompatible ... " error before calling `dlclose(handle)`.
2023-03-21 19:10:19 +09:00
Sergey Fedorov 567725ed30
Fix and improve coroutines for Darwin (macOS) ppc/ppc64. (#5975) 2022-10-19 23:49:45 +13:00
Nobuyoshi Nakada f08fcd0e80
Fix possible use of undefined macros on very old macOS [ci skip] 2022-10-17 18:36:08 +09:00
Takashi Kokubun 5b21e94beb Expand tabs [ci skip]
[Misc #18891]
2022-07-21 09:42:04 -07:00
Nobuyoshi Nakada 50cfecd015
Show ABI incompatible binary path 2022-07-17 09:01:33 +09:00
Nobuyoshi Nakada fc8020c68e
[Bug #18879] Fix macOS version detections
macOS's AvailabilityMacros.h does not contain macros for future
versions.  If a version macro is not defined, consider only earlier
versions to be targeted.
2022-06-27 01:08:46 +09:00
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