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

204 Коммитов

Автор SHA1 Сообщение Дата
Daisuke Fujimura (fd0) 9c8c140d73 Avoid dangling pointer on cygwin 2024-10-25 20:52:32 +09:00
Nobuyoshi Nakada 9a90cd2284 Cast via `uintptr_t` function pointer between object pointer
- ISO C forbids conversion of function pointer to object pointer type
- ISO C forbids conversion of object pointer to function pointer type
2024-10-08 23:29:49 +09:00
Peter Zhu 52a0dfd4bf Revert all changes to dln.c, dmydln.c, dln.h for the shared GC 2024-07-10 14:28:10 -04:00
Peter Zhu f64c97418b Allow RUBY_GC_LIBRARY_PATH to be set in miniruby
miniruby is used by tool/runruby.rb, so we need to ensure we don't rb_bug
when RUBY_GC_LIBRARY_PATH is set so we can run tests using the make
commands. This commit changes it to warn instead.
2024-04-26 17:02:08 -04:00
Peter Zhu 057b69cfdf Pass string error buffer into dln_open
On Windows, the error exists on the stack so we should pass an error
buffer from the caller.
2024-04-24 13:10:06 -04:00
Peter Zhu b9109b270d Get error from dln_open when USE_SHARED_GC
Before, if dln_open failed to open RUBY_GC_LIBRARY_PATH, it would segfault
because it would try to raise an error, which cannot happen because the
GC has not been initialized yet.

This commit changes dln_open to return the error that occurred so the
caller can handle the error.
2024-04-23 15:29:42 -04:00
Matt Valentine-House 065710c0f5 Initialize external GC Library
Co-Authored-By: Peter Zhu <peter@peterzhu.ca>
2024-04-15 19:50:47 +01:00
Nobuyoshi Nakada e1c684e471
Refactor to use `struct string_part` 2024-02-22 15:43:46 +09:00
Nobuyoshi Nakada 97a39ccc2c
Split `init_funcname`
Extract `build_funcname` that takes the prefix as an argument, and
`concat_funcname` that concats the parts.
2024-02-22 15:43:46 +09:00
Nobuyoshi Nakada 7b3e05c392
Do not define ABI version in statically linked objects
It is for dynamically loading, useless for statically linked objects.
2024-02-04 20:33:45 +09:00
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