enable rtti

This commit is contained in:
blueloveTH 2024-02-29 10:57:15 +08:00
parent ec044397e6
commit a2e7846662
7 changed files with 8 additions and 6 deletions

View File

@ -8,11 +8,11 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /utf-8 /O2")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -O2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -frtti -O2")
# disable -Wshorten-64-to-32 for apple
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-shorten-64-to-32")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -frtti -Wno-shorten-64-to-32")
endif()
endif()

View File

@ -58,6 +58,7 @@ It is safe to use `main` branch in production.
To compile it with your project, these flags must be set:
+ `--std=c++17` flag must be set
+ RTTI must be enabled
+ Exception must be enabled
+ For MSVC, `/utf-8` flag must be set

View File

@ -82,7 +82,7 @@ with open("amalgamated/main.cpp", "wt", encoding='utf-8', newline='\n') as f:
f.write(text)
if sys.platform in ['linux', 'darwin']:
ok = os.system("clang++ -o main amalgamated/main.cpp -O1 --std=c++17 -stdlib=libc++")
ok = os.system("clang++ -o main amalgamated/main.cpp -O1 --std=c++17 -frtti -stdlib=libc++")
if ok == 0:
print("Test build success!")

View File

@ -22,7 +22,7 @@ SRC=$(find src/ -name "*.cpp")
echo "> Compiling and linking source files... "
FLAGS="-std=c++17 -O1 -stdlib=libc++ -Wfatal-errors -Iinclude"
FLAGS="-std=c++17 -O1 -stdlib=libc++ -frtti -Wfatal-errors -Iinclude"
if [[ "$OSTYPE" == "darwin"* ]]; then
LIB_EXTENSION=".dylib"

View File

@ -4,4 +4,4 @@ rm -rf web/lib
mkdir web/lib
SRC=$(find src/ -name "*.cpp")
em++ $SRC -Iinclude/ -fexceptions -s -Os -sEXPORTED_FUNCTIONS=_pkpy_new_repl,_pkpy_repl_input,_pkpy_new_vm -sEXPORTED_RUNTIME_METHODS=ccall -o web/lib/pocketpy.js
em++ $SRC -Iinclude/ -fexceptions -frtti -s -Os -sEXPORTED_FUNCTIONS=_pkpy_new_repl,_pkpy_repl_input,_pkpy_new_vm -sEXPORTED_RUNTIME_METHODS=ccall -o web/lib/pocketpy.js

View File

@ -1,5 +1,5 @@
SRC=$(find src/ -name "*.cpp")
FLAGS="-std=c++17 -O1 -stdlib=libc++ -Iinclude -W -Wno-unused-parameter"
FLAGS="-std=c++17 -O1 -stdlib=libc++ -Iinclude -frtti -W -Wno-unused-parameter"
clang++ $FLAGS -o main -O1 src2/main.cpp $SRC

View File

@ -43,6 +43,7 @@ It is safe to use `main` branch in production.
To compile it with your project, these flags must be set:
+ `--std=c++17` flag must be set
+ RTTI must be enabled
+ Exception must be enabled
+ For MSVC, `/utf-8` flag must be set