File tree Expand file tree Collapse file tree 3 files changed +32
-19
lines changed Expand file tree Collapse file tree 3 files changed +32
-19
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ option(ASAR_GEN_EXE "Build Asar standalone application" ON)
7
7
option (ASAR_GEN_DLL "Build Asar shared library" ON )
8
8
option (ASAR_COVERAGE "Build Asar with coverage tracking support" ON )
9
9
option (ASAR_GEN_LIB "Build Asar static library" ON )
10
+ option (ASAR_USE_THREADS "Run Asar in a new thread to alleviate stack usage problems" ON )
10
11
if (MSVC )
11
12
message (STATUS "In MSVC you can override MSVC_LIB_TYPE, valid values are D for dynamic and T for static" )
12
13
endif ()
@@ -92,9 +93,11 @@ macro(set_asar_shared_properties target msvc_lib_type_param enable_sanitizer)
92
93
target_compile_definitions (${target} PRIVATE "linux" )
93
94
target_compile_definitions (${target} PRIVATE "stricmp=strcasecmp" )
94
95
95
- set (THREADS_PREFER_PTHREAD_FLAG ON )
96
- find_package (Threads REQUIRED)
97
- target_link_libraries (${target} PRIVATE Threads::Threads)
96
+ if (ASAR_USE_THREADS)
97
+ set (THREADS_PREFER_PTHREAD_FLAG ON )
98
+ find_package (Threads REQUIRED)
99
+ target_link_libraries (${target} PRIVATE Threads::Threads)
100
+ endif ()
98
101
endif ()
99
102
100
103
@@ -136,6 +139,10 @@ macro(set_asar_shared_properties target msvc_lib_type_param enable_sanitizer)
136
139
# for some reason this isn't available on MSVC?
137
140
target_compile_features (${target} PRIVATE c_std_99)
138
141
endif ()
142
+
143
+ if (NOT (ASAR_USE_THREADS))
144
+ target_compile_definitions (${target} PRIVATE NO_USE_THREADS)
145
+ endif ()
139
146
endmacro ()
140
147
141
148
Original file line number Diff line number Diff line change @@ -181,10 +181,12 @@ const char* get_current_block();
181
181
const char * get_previous_file_name ();
182
182
int get_previous_file_line_no ();
183
183
184
+ #if !defined(NO_USE_THREADS) && !defined(RUN_VIA_THREAD)
184
185
// RPG Hacker: This is currently disabled for debug builds, because it causes random crashes
185
186
// when used in combination with -fsanitize=address.
186
- #if defined(_WIN32) && defined(NDEBUG)
187
- # define RUN_VIA_FIBER
188
- #else
189
- # define RUN_VIA_THREAD
187
+ # if defined(_WIN32) && defined(NDEBUG)
188
+ # define RUN_VIA_FIBER
189
+ # else
190
+ # define RUN_VIA_THREAD
191
+ # endif
190
192
#endif
Original file line number Diff line number Diff line change @@ -545,19 +545,23 @@ int main(int argc, const char * argv[])
545
545
546
546
auto execute_patch = [&]()
547
547
{
548
- for (pass=0 ;pass<3 ;pass++)
549
- {
550
- // pass 1: find which bank all labels are in, for label optimizations
551
- // freespaces are listed as above 0xFFFFFF, to find if it's in the ROM or if it's dynamic
552
- // pass 2: find where exactly all labels are
553
- // pass 3: assemble it all
554
- initstuff ();
555
- assemblefile (asmname);
556
- // RPG Hacker: Necessary, because finishpass() can throws warning and errors.
557
- callstack_push cs_push (callstack_entry_type::FILE, filesystem->create_absolute_path (nullptr , asmname));
558
- finishpass ();
548
+ try {
549
+ for (pass=0 ;pass<3 ;pass++)
550
+ {
551
+ // pass 1: find which bank all labels are in, for label optimizations
552
+ // freespaces are listed as above 0xFFFFFF, to find if it's in the ROM or if it's dynamic
553
+ // pass 2: find where exactly all labels are
554
+ // pass 3: assemble it all
555
+ initstuff ();
556
+ assemblefile (asmname);
557
+ // RPG Hacker: Necessary, because finishpass() can throws warning and errors.
558
+ callstack_push cs_push (callstack_entry_type::FILE, filesystem->create_absolute_path (nullptr , asmname));
559
+ finishpass ();
560
+ }
561
+ return true ;
562
+ } catch (errfatal&) {
563
+ return false ;
559
564
}
560
- return true ;
561
565
};
562
566
#if defined(RUN_VIA_FIBER)
563
567
run_as_fiber (execute_patch);
You can’t perform that action at this time.
0 commit comments