Skip to content

Commit 9c22da4

Browse files
committed
sed the generated enum yytokentype
to avoid LTO -Wodr warnings. yacc doesnt support this yet
1 parent 894ecda commit 9c22da4

File tree

6 files changed

+30
-4
lines changed

6 files changed

+30
-4
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ else()
242242
message(STATUS "IPO / LTO not supported: <${error}>")
243243
endif()
244244

245+
find_program(SED sed gsed)
246+
245247
add_subdirectory(src)
246248
add_subdirectory(regression)
247249
add_subdirectory(unit)

src/CMakeLists.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,15 @@ macro(generic_bison name)
4141
COMPILE_FLAGS "${bison_warnings_as_errors} -pyy${name}"
4242
)
4343
set(renamed_parser_header "${CMAKE_CURRENT_BINARY_DIR}/${bison_header}")
44-
add_custom_command(OUTPUT "${renamed_parser_header}"
45-
COMMAND "${CMAKE_COMMAND}" -E copy "${BISON_parser_OUTPUT_HEADER}" "${renamed_parser_header}"
46-
MAIN_DEPENDENCY "${BISON_parser_OUTPUT_HEADER}"
47-
)
44+
if(${SED} STREQUAL "SED-NOTFOUND")
45+
add_custom_command(OUTPUT "${renamed_parser_header}"
46+
COMMAND "${CMAKE_COMMAND}" -E copy "${BISON_parser_OUTPUT_HEADER}" "${renamed_parser_header}"
47+
MAIN_DEPENDENCY "${BISON_parser_OUTPUT_HEADER}")
48+
else()
49+
add_custom_command(OUTPUT "${renamed_parser_header}"
50+
COMMAND ${SED} -e "s,enum yytokentype,enum yytokentype_${name}," <${BISON_parser_OUTPUT_HEADER} >${renamed_parser_header}
51+
MAIN_DEPENDENCY "${BISON_parser_OUTPUT_HEADER}")
52+
endif()
4853
list(REMOVE_ITEM BISON_parser_OUTPUTS "${BISON_parser_OUTPUT_HEADER}")
4954
list(APPEND BISON_parser_OUTPUTS "${renamed_parser_header}")
5055
endmacro(generic_bison)

src/ansi-c/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ all: ansi-c$(LIBEXT)
8787

8888
ansi_c_y.tab.cpp: parser.y
8989
$(YACC) $(YFLAGS) -pyyansi_c parser.y --defines=ansi_c_y.tab.h -o $@
90+
$(SED) -e's,enum yytokentype,enum yytokentype_ansi,' \
91+
<ansi_c_y.tab.h >ansi_c_y.tab.h.tmp && \
92+
mv ansi_c_y.tab.h.tmp ansi_c_y.tab.h
9093

9194
ansi_c_y.tab.h: ansi_c_y.tab.cpp
9295

src/common

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ endif
9898
ifeq ($(origin LEX),default)
9999
LEX = flex
100100
endif
101+
ifeq ($(origin SED),default)
102+
SED = sed
103+
endif
101104

102105
else ifeq ($(BUILD_ENV_),Cygwin)
103106
# use these for Cygwin:
@@ -130,6 +133,9 @@ endif
130133
ifeq ($(origin LEX),default)
131134
LEX = flex
132135
endif
136+
ifeq ($(origin SED),default)
137+
SED = sed
138+
endif
133139

134140

135141
else ifeq ($(BUILD_ENV_),MSVC)
@@ -158,6 +164,10 @@ endif
158164
ifeq ($(origin LEX),default)
159165
LEX = win_flex
160166
endif
167+
ifeq ($(origin SED),default)
168+
# on MSVC there is no lto
169+
SED = rem
170+
endif
161171

162172

163173
else

src/jsil/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jsil$(LIBEXT): $(OBJ)
2929

3030
jsil_y.tab.cpp: parser.y
3131
$(YACC) $(YFLAGS) -pyyjsil parser.y --defines=jsil_y.tab.h -o $@
32+
$(SED) -e's,enum yytokentype,enum yytokentype_jsil,' \
33+
<jsil_y.tab.h >jsil_y.tab.h.tmp && \
34+
mv jsil_y.tab.h.tmp jsil_y.tab.h
3235

3336
jsil_y.tab.h: jsil_y.tab.cpp
3437

src/statement-list/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ all: statement-list$(LIBEXT)
3131

3232
statement_list_y.tab.cpp: parser.y
3333
$(YACC) $(YFLAGS) -pyystatement_list parser.y --defines=statement_list_y.tab.h -o $@
34+
$(SED) -e's,enum yytokentype,enum yytokentype_stmt,' \
35+
<statement_list_y.tab.h >statement_list_y.tab.h.tmp && \
36+
mv statement_list_y.tab.h.tmp statement_list_y.tab.h
3437

3538
statement_list_y.tab.h: statement_list_y.tab.cpp
3639

0 commit comments

Comments
 (0)