Ruby 3.5.0dev (2025-02-23 revision fd882fb6819fb8b48b09e24ff71748d1bae35e43)
main.c (fd882fb6819fb8b48b09e24ff71748d1bae35e43)
1/**********************************************************************
2
3 main.c -
4
5 $Author$
6 created at: Fri Aug 19 13:19:58 JST 1994
7
8 Copyright (C) 1993-2007 Yukihiro Matsumoto
9
10**********************************************************************/
11
20#undef RUBY_EXPORT
21#include "ruby.h"
22#include "vm_debug.h"
23#include "internal/sanitizers.h"
24#ifdef HAVE_LOCALE_H
25#include <locale.h>
26#endif
27
28#if defined RUBY_DEVEL && !defined RUBY_DEBUG_ENV
29# define RUBY_DEBUG_ENV 1
30#endif
31#if defined RUBY_DEBUG_ENV && !RUBY_DEBUG_ENV
32# undef RUBY_DEBUG_ENV
33#endif
34
35static int
36rb_main(int argc, char **argv)
37{
39 ruby_init();
40 return ruby_run_node(ruby_options(argc, argv));
41}
42
43#if defined(__wasm__) && !defined(__EMSCRIPTEN__)
44int rb_wasm_rt_start(int (main)(int argc, char **argv), int argc, char **argv);
45#define rb_main(argc, argv) rb_wasm_rt_start(rb_main, argc, argv)
46#endif
47
48#ifdef _WIN32
49#define main(argc, argv) w32_main(argc, argv)
50static int main(int argc, char **argv);
51int wmain(void) {return main(0, NULL);}
52#endif
53
54int
55main(int argc, char **argv)
56{
57#if defined(RUBY_DEBUG_ENV) || USE_RUBY_DEBUG_LOG
58 ruby_set_debug_option(getenv("RUBY_DEBUG"));
59#endif
60#ifdef HAVE_LOCALE_H
61 setlocale(LC_CTYPE, "");
62#endif
63
64 ruby_sysinit(&argc, &argv);
65 return rb_main(argc, argv);
66}
67
68#ifdef RUBY_ASAN_ENABLED
69/* Compile in the ASAN options Ruby needs, rather than relying on environment variables, so
70 * that even tests which fork ruby with a clean environment will run ASAN with the right
71 * settings */
72RUBY_SYMBOL_EXPORT_BEGIN
73const char *
74__asan_default_options(void)
75{
76 return "use_sigaltstack=0:detect_leaks=0";
77}
78RUBY_SYMBOL_EXPORT_END
79#endif
#define RUBY_INIT_STACK
A convenience macro to call ruby_init_stack().
void ruby_init(void)
Calls ruby_setup() and check error.
Definition eval.c:95
void ruby_sysinit(int *argc, char ***argv)
Initializes the process for libruby.
Definition ruby.c:3180