Skip to content

Commit 0533b4b

Browse files
author
Tor Didriksen
committed
Bug#27470071 ERROR C1083: CANNOT OPEN INCLUDE FILE: 'LEX_TOKEN.H'
This is a bacport to 5.6 of four bugfixes in 5.7 Bug#20678411 BROKEN MAKEFILE DEPENDENCY: SQL_YACC.YY AND LEX_TOKEN.H Add explicit dependency sql_yacc.cc.o => lex_token.h Bug#19060850: SQL_YACC.CC REGENERATED TWICE IN WINDOWS BUILD, CAN LEAD TO BUILD BREAK Run Bison separately for libmysqld so that independent copies of sql_yacc.h/sql_yacc.cc are generated. This avoids the Windows build break because of libmysqld compilation of sql_yacc.cc while it is being generated. Bug#21680733 WINDOWS (10) BUILD MAY COMPILE SQL_YACC.CC BEFORE LEX_TOKEN.H HAS BEEN GENERATED Problem: build may fail non-deterministically when when building in parallel. Solution: build local copy lex_token.h, and add explicit dependency for it. Bug#24931655 RACE CONDITION BUILDING LEX_HASH.H Mysql cluster is experiencing race conditions generating lex_hash.h Fix: Generate lex_hash.h locally for the embedded server, rather than picking it up from the sql/ build directory.
1 parent 27e3223 commit 0533b4b

File tree

3 files changed

+104
-49
lines changed

3 files changed

+104
-49
lines changed

cmake/bison.cmake

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# Copyright (c) 2009 Sun Microsystems, Inc.
2-
# Use is subject to license terms.
1+
# Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
32
#
43
# This program is free software; you can redistribute it and/or modify
54
# it under the terms of the GNU General Public License as published by
@@ -12,18 +11,13 @@
1211
#
1312
# You should have received a copy of the GNU General Public License
1413
# along with this program; if not, write to the Free Software
15-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
14+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1615

17-
IF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
18-
# On Solaris, /opt/csw often contains a newer bison
19-
IF(NOT BISON_EXECUTABLE AND EXISTS /opt/csw/bin/bison)
20-
SET(BISON_EXECUTABLE /opt/csw/bin/bison)
21-
ENDIF()
22-
ENDIF()
2316
FIND_PROGRAM(BISON_EXECUTABLE bison DOC "path to the bison executable")
2417
MARK_AS_ADVANCED(BISON_EXECUTABLE "")
18+
2519
IF(NOT BISON_EXECUTABLE)
26-
MESSAGE("Warning: Bison executable not found in PATH")
20+
MESSAGE(WARNING "Bison executable not found in PATH")
2721
ELSEIF(BISON_EXECUTABLE AND NOT BISON_USABLE)
2822
# Check version as well
2923
EXEC_PROGRAM(${BISON_EXECUTABLE} ARGS --version OUTPUT_VARIABLE BISON_VERSION_STR)
@@ -33,19 +27,26 @@ ELSEIF(BISON_EXECUTABLE AND NOT BISON_USABLE)
3327
STRING(REGEX REPLACE ".* ([0-9]+)\\.([0-9]+)" "\\1" BISON_VERSION_MAJOR "${FIRST_LINE}")
3428
STRING(REGEX REPLACE ".* ([0-9]+)\\.([0-9]+)" "\\2" BISON_VERSION_MINOR "${FIRST_LINE}")
3529
IF (BISON_VERSION_MAJOR LESS 2)
36-
MESSAGE("Warning: bison version is old. please update to version 2")
30+
MESSAGE(WARNING "Bison version is old. please update to version 2")
3731
ELSE()
3832
SET(BISON_USABLE 1 CACHE INTERNAL "Bison version 2 or higher")
3933
ENDIF()
4034
ENDIF()
4135

36+
37+
# Handle out-of-source build from source package with possibly broken
38+
# bison. Copy bison output to from source to build directory, if not already
39+
# there
40+
MACRO(COPY_BISON_OUTPUT input_cc input_h output_cc output_h)
41+
IF(EXISTS ${input_cc} AND NOT EXISTS ${output_cc})
42+
CONFIGURE_FILE(${input_cc} ${output_cc} COPYONLY)
43+
CONFIGURE_FILE(${input_h} ${output_h} COPYONLY)
44+
ENDIF()
45+
ENDMACRO()
46+
47+
4248
# Use bison to generate C++ and header file
4349
MACRO (RUN_BISON input_yy output_cc output_h)
44-
IF(BISON_TOO_OLD)
45-
IF(EXISTS ${output_cc} AND EXISTS ${output_h})
46-
SET(BISON_USABLE FALSE)
47-
ENDIF()
48-
ENDIF()
4950
IF(BISON_USABLE)
5051
ADD_CUSTOM_COMMAND(
5152
OUTPUT ${output_cc}
@@ -61,7 +62,7 @@ MACRO (RUN_BISON input_yy output_cc output_h)
6162
IF(EXISTS ${output_cc} AND EXISTS ${output_h})
6263
IF(${input_yy} IS_NEWER_THAN ${output_cc} OR ${input_yy} IS_NEWER_THAN ${output_h})
6364
# Possibly timestamps are messed up in source distribution.
64-
MESSAGE("Warning: no usable bison found, ${input_yy} will not be rebuilt.")
65+
MESSAGE(WARNING "No usable bison found, ${input_yy} will not be rebuilt.")
6566
ENDIF()
6667
ELSE()
6768
# Output files are missing, bail out.

libmysqld/CMakeLists.txt

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -29,14 +29,26 @@ INCLUDE_DIRECTORIES(
2929
${CMAKE_SOURCE_DIR}/sql/backup
3030
)
3131

32+
# We should generate these separately for libmysqld to avoid
33+
# compiling them for libmysqld while they are generated for sql.
34+
SET(GEN_YACC_SOURCES
35+
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
36+
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
37+
)
38+
3239
SET(GEN_SOURCES
33-
${CMAKE_BINARY_DIR}/sql/sql_yacc.h
34-
${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
3540
${CMAKE_BINARY_DIR}/sql/sql_builtin.cc
36-
${CMAKE_BINARY_DIR}/sql/lex_hash.h
3741
)
3842

39-
SET_SOURCE_FILES_PROPERTIES(${GEN_SOURCES} PROPERTIES GENERATED TRUE)
43+
ADD_CUSTOM_COMMAND(
44+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h
45+
COMMAND gen_lex_hash > lex_hash.h
46+
DEPENDS gen_lex_hash
47+
)
48+
49+
SET_SOURCE_FILES_PROPERTIES(${GEN_YACC_SOURCES}
50+
${GEN_SOURCES}
51+
PROPERTIES GENERATED TRUE)
4052

4153
FOREACH(file ${SQL_EXPORTED_SOURCES})
4254
LIST(APPEND IMPORTED_SOURCES "../sql/${file}")
@@ -48,6 +60,7 @@ SET(SQL_EMBEDDED_SOURCES
4860
libmysqld.c
4961
${GEN_SOURCES}
5062
${MYSYS_LIBWRAP_SOURCE}
63+
${GEN_YACC_SOURCES}
5164
../client/get_password.c
5265
../libmysql/errmsg.c
5366
../libmysql/libmysql.c
@@ -79,9 +92,45 @@ SET(SQL_EMBEDDED_SOURCES
7992
)
8093

8194

95+
96+
# Handle out-of-source build from source package with possibly broken
97+
# bison. Copy bison output to from source to build directory, if not already
98+
# there
99+
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/bison.cmake)
100+
COPY_BISON_OUTPUT(
101+
${CMAKE_SOURCE_DIR}/sql/sql_yacc.cc
102+
${CMAKE_SOURCE_DIR}/sql/sql_yacc.h
103+
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
104+
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
105+
)
106+
107+
RUN_BISON(
108+
${CMAKE_SOURCE_DIR}/sql/sql_yacc.yy
109+
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
110+
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
111+
)
112+
113+
ADD_CUSTOM_COMMAND(
114+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lex_token.h
115+
COMMAND gen_lex_token > lex_token.h
116+
DEPENDS gen_lex_token
117+
)
118+
119+
SET_SOURCE_FILES_PROPERTIES(
120+
${CMAKE_CURRENT_BINARY_DIR}/sql/lex_token.h
121+
PROPERTIES GENERATED 1)
122+
123+
SET_SOURCE_FILES_PROPERTIES(
124+
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
125+
${CMAKE_SOURCE_DIR}/sql/sql_digest.cc
126+
PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/lex_token.h
127+
)
128+
129+
ADD_CUSTOM_TARGET(GenYaccEmbeddedSource DEPENDS ${GEN_YACC_SOURCES})
130+
82131
ADD_CONVENIENCE_LIBRARY(sql_embedded ${SQL_EMBEDDED_SOURCES})
83132
DTRACE_INSTRUMENT(sql_embedded)
84-
ADD_DEPENDENCIES(sql_embedded GenError GenServerSource)
133+
ADD_DEPENDENCIES(sql_embedded GenError GenServerSource GenYaccEmbeddedSource)
85134

86135
# On Windows, static embedded server library is called mysqlserver.lib
87136
# On Unix, it is libmysqld.a
@@ -93,8 +142,8 @@ ENDIF()
93142

94143

95144
SET(LIBS
96-
dbug strings regex mysys mysys_ssl vio
97-
${ZLIB_LIBRARY} ${SSL_LIBRARIES}
145+
dbug strings regex mysys mysys_ssl vio
146+
${ZLIB_LIBRARY} ${SSL_LIBRARIES}
98147
${LIBWRAP} ${LIBCRYPT} ${LIBDL}
99148
${MYSQLD_STATIC_PLUGIN_LIBS}
100149
sql_embedded
@@ -112,6 +161,8 @@ FOREACH(LIB ${LIBS})
112161
ENDIF()
113162
ENDFOREACH()
114163

164+
LIST(REMOVE_DUPLICATES EMBEDDED_LIBS)
165+
115166
MERGE_LIBRARIES(mysqlserver STATIC ${EMBEDDED_LIBS}
116167
OUTPUT_NAME ${MYSQLSERVER_OUTPUT_NAME} COMPONENT Embedded)
117168

@@ -145,7 +196,7 @@ IF(WITH_EMBEDDED_SHARED_LIBRARY)
145196
)
146197

147198
GET_TARGET_PROPERTY(libmysqld_link_flags libmysqld LINK_FLAGS)
148-
IF(NOT libmysqld_link_flag)
199+
IF(NOT libmysqld_link_flags)
149200
SET(libmysqld_link_flags)
150201
ENDIF()
151202
SET(libmysqld_link_flags

sql/CMakeLists.txt

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -13,6 +13,7 @@
1313
# along with this program; if not, write to the Free Software
1414
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1515

16+
1617
INCLUDE_DIRECTORIES(
1718
${CMAKE_SOURCE_DIR}/include
1819
${CMAKE_SOURCE_DIR}/sql
@@ -35,8 +36,8 @@ SET(GEN_DIGEST_SOURCES
3536
)
3637

3738
SET_SOURCE_FILES_PROPERTIES(${GEN_SOURCES}
38-
${CONF_SOURCES}
3939
${GEN_DIGEST_SOURCES}
40+
${CONF_SOURCES}
4041
PROPERTIES GENERATED 1)
4142

4243
# Gen_lex_token
@@ -193,8 +194,8 @@ SET(SQL_EXPORTED_SOURCES ${SQL_SHARED_SOURCES} PARENT_SCOPE)
193194

194195
SET(SQL_SOURCE
195196
${GEN_SOURCES}
196-
${CONF_SOURCES}
197197
${GEN_DIGEST_SOURCES}
198+
${CONF_SOURCES}
198199
${MYSYS_LIBWRAP_SOURCE}
199200
${SQL_SHARED_SOURCES}
200201
../libmysql/errmsg.c
@@ -277,7 +278,8 @@ ELSE()
277278
SET(MYSQLD_SOURCE main.cc ${DTRACE_PROBES_ALL})
278279
ENDIF()
279280

280-
MYSQL_ADD_EXECUTABLE(mysqld ${MYSQLD_SOURCE} DESTINATION ${INSTALL_SBINDIR} COMPONENT Server)
281+
MYSQL_ADD_EXECUTABLE(mysqld
282+
${MYSQLD_SOURCE} DESTINATION ${INSTALL_SBINDIR} COMPONENT Server)
281283

282284
OPTION(DEBUG_EXTNAME "Build server as mysqld-debug (debug builds only)" OFF)
283285
MARK_AS_ADVANCED(DEBUG_EXTNAME)
@@ -304,9 +306,11 @@ IF(NOT WITHOUT_DYNAMIC_PLUGINS)
304306
SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_FLAGS "${mysqld_link_flags} -Wl,--export-all-symbols")
305307
ENDIF()
306308
IF(MSVC)
307-
# Set module definition file. Also use non-incremental linker,
308-
# incremental appears to crash from time to time,if used with /DEF option
309-
SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_FLAGS "${mysqld_link_flags} /DEF:mysqld.def /INCREMENTAL:NO")
309+
# Set module definition file.
310+
# Also use non-incremental linker, incremental appears to crash from
311+
# time to time,if used with /DEF option
312+
SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_FLAGS
313+
"${mysqld_link_flags} /DEF:mysqld.def /INCREMENTAL:NO")
310314

311315
FOREACH (CORELIB sql mysys mysys_ssl dbug strings)
312316
GET_TARGET_PROPERTY(LOC ${CORELIB} LOCATION)
@@ -367,25 +371,26 @@ ENDIF()
367371
# Handle out-of-source build from source package with possibly broken
368372
# bison. Copy bison output to from source to build directory, if not already
369373
# there
370-
IF (NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
371-
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.cc)
372-
IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc)
373-
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.cc
374-
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc COPYONLY)
375-
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.h
376-
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h COPYONLY)
377-
ENDIF()
378-
ENDIF()
379-
ENDIF()
380-
381-
382374
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/bison.cmake)
375+
COPY_BISON_OUTPUT(
376+
${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.cc
377+
${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.h
378+
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
379+
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
380+
)
381+
383382
RUN_BISON(
384383
${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.yy
385384
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
386385
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
387386
)
388387

388+
SET_SOURCE_FILES_PROPERTIES(
389+
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
390+
${CMAKE_CURRENT_SOURCE_DIR}/sql_digest.cc
391+
PROPERTIES OBJECT_DEPENDS ${GEN_DIGEST_SOURCES}
392+
)
393+
389394
# Gen_lex_hash
390395
ADD_EXECUTABLE(gen_lex_hash gen_lex_hash.cc)
391396

@@ -409,16 +414,15 @@ ADD_CUSTOM_TARGET(
409414
DEPENDS ${GEN_DIGEST_SOURCES}
410415
)
411416

412-
#Need this only for embedded
413-
SET_TARGET_PROPERTIES(GenServerSource PROPERTIES EXCLUDE_FROM_ALL TRUE)
414417

415418
IF(WIN32 OR HAVE_DLOPEN AND NOT DISABLE_SHARED)
416419
ADD_LIBRARY(udf_example MODULE udf_example.cc)
417420
SET_TARGET_PROPERTIES(udf_example PROPERTIES PREFIX "")
418421
# udf_example depends on strings
419422
IF(WIN32)
420423
IF(MSVC)
421-
SET_TARGET_PROPERTIES(udf_example PROPERTIES LINK_FLAGS "/DEF:${CMAKE_CURRENT_SOURCE_DIR}/udf_example.def")
424+
SET_TARGET_PROPERTIES(udf_example
425+
PROPERTIES LINK_FLAGS "/DEF:${CMAKE_CURRENT_SOURCE_DIR}/udf_example.def")
422426
ENDIF()
423427
TARGET_LINK_LIBRARIES(udf_example strings)
424428
ELSE()
@@ -502,4 +506,3 @@ ENDIF()
502506
ADD_CUSTOM_TARGET(show-dist-name
503507
COMMAND ${CMAKE_COMMAND} -E echo "${CPACK_PACKAGE_FILE_NAME}"
504508
)
505-

0 commit comments

Comments
 (0)