Skip to content

Commit 37b10e7

Browse files
committed
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.
1 parent 8e7a8ad commit 37b10e7

File tree

3 files changed

+57
-33
lines changed

3 files changed

+57
-33
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, 2014, 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: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,21 @@ INCLUDE_DIRECTORIES(
3333
${BOOST_INCLUDE_DIR}
3434
)
3535

36+
# We should generate these separately for libmysqld to avoid
37+
# compiling them for libmysqld while they are generated for sql.
38+
SET(GEN_YACC_SOURCES
39+
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
40+
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
41+
)
42+
3643
SET(GEN_SOURCES
37-
${CMAKE_BINARY_DIR}/sql/sql_yacc.h
38-
${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
3944
${CMAKE_BINARY_DIR}/sql/sql_builtin.cc
4045
${CMAKE_BINARY_DIR}/sql/lex_hash.h
4146
)
4247

43-
SET_SOURCE_FILES_PROPERTIES(${GEN_SOURCES} PROPERTIES GENERATED TRUE)
48+
SET_SOURCE_FILES_PROPERTIES(${GEN_YACC_SOURCES}
49+
${GEN_SOURCES}
50+
PROPERTIES GENERATED TRUE)
4451

4552
FOREACH(file ${SQL_EXPORTED_SOURCES})
4653
LIST(APPEND IMPORTED_SOURCES "../sql/${file}")
@@ -51,6 +58,7 @@ SET(SQL_EMBEDDED_SOURCES
5158
lib_sql.cc
5259
libmysqld.c
5360
${GEN_SOURCES}
61+
${GEN_YACC_SOURCES}
5462
../client/get_password.c
5563
../libmysql/errmsg.c
5664
../libmysql/libmysql.c
@@ -97,9 +105,29 @@ IF(HAVE_MY_TIMER)
97105
SET(SQL_EMBEDDED_SOURCES ${SQL_EMBEDDED_SOURCES} ../sql/sql_timer.cc)
98106
ENDIF()
99107

108+
109+
# Handle out-of-source build from source package with possibly broken
110+
# bison. Copy bison output to from source to build directory, if not already
111+
# there
112+
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/bison.cmake)
113+
COPY_BISON_OUTPUT(
114+
${CMAKE_SOURCE_DIR}/sql/sql_yacc.cc
115+
${CMAKE_SOURCE_DIR}/sql/sql_yacc.h
116+
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
117+
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
118+
)
119+
120+
RUN_BISON(
121+
${CMAKE_SOURCE_DIR}/sql/sql_yacc.yy
122+
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
123+
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
124+
)
125+
126+
ADD_CUSTOM_TARGET(GenYaccEmbeddedSource DEPENDS ${GEN_YACC_SOURCES})
127+
100128
ADD_CONVENIENCE_LIBRARY(sql_embedded ${SQL_EMBEDDED_SOURCES})
101129
DTRACE_INSTRUMENT(sql_embedded)
102-
ADD_DEPENDENCIES(sql_embedded GenError GenServerSource)
130+
ADD_DEPENDENCIES(sql_embedded GenError GenServerSource GenYaccEmbeddedSource)
103131

104132
# On Windows, static embedded server library is called mysqlserver.lib
105133
# On Unix, it is libmysqld.a

sql/CMakeLists.txt

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -444,19 +444,14 @@ ENDIF()
444444
# Handle out-of-source build from source package with possibly broken
445445
# bison. Copy bison output to from source to build directory, if not already
446446
# there
447-
IF (NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
448-
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.cc)
449-
IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc)
450-
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.cc
451-
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc COPYONLY)
452-
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.h
453-
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h COPYONLY)
454-
ENDIF()
455-
ENDIF()
456-
ENDIF()
457-
458-
459447
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/bison.cmake)
448+
COPY_BISON_OUTPUT(
449+
${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.cc
450+
${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.h
451+
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
452+
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
453+
)
454+
460455
RUN_BISON(
461456
${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.yy
462457
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc

0 commit comments

Comments
 (0)