stoneatom / stonedb

StoneDB is an Open-Source MySQL HTAP and MySQL-Native DataBase for OLTP, Real-Time Analytics, a counterpart of MySQLHeatWave. (https://stonedb.io)
https://stonedb.io/
GNU General Public License v2.0
861 stars 139 forks source link

bug: compile Error, ‘STONEDB_TAG_NAME’ was not declared in this scope, #1328

Open davidshiz opened 1 year ago

davidshiz commented 1 year ago

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

Describe the problem

When fock a branch in your own code repo, you cannot compile successfully. because your own code repo have no tag. It is recommended to decouple from tags when compiling code.

/stonedb/libbinlogevents/include/rows_event.h: In constructor ‘binary_log::Table_map_event::Table_map_event(const Table_id&, long unsigned int, const char*, size_t, const char*, size_t)’:
/stonedb/libbinlogevents/include/rows_event.h:428:20: warning: implicitly-declared ‘constexpr Table_id::Table_id(const Table_id&)’ is deprecated [-Wdeprecated-copy]
  428 |       m_null_bits(0)
      |                    ^
In file included from /riyao/stonedb/sql/table.h:37,
                 from /riyao/stonedb/sql/field.h:37,
                 from /riyao/stonedb/sql/protocol_classic.h:27,
                 from /riyao/stonedb/sql/sql_class.h:40,
                 from /riyao/stonedb/sql/sql_parse.h:29,
                 from /riyao/stonedb/sql/mysqld.cc:57:
/stonedb/libbinlogevents/include/table_id.h:53:8: note: because ‘Table_id’ has user-provided ‘void Table_id::operator=(const Table_id&)’
   53 |   void operator=(const Table_id &tid) { m_id = tid.m_id; }
      |        ^~~~~~~~
/stonedb/sql/mysqld.cc: In function ‘void set_server_version()’:
/stonedb/sql/mysqld.cc:8134:31: error: ‘STONEDB_TAG_NAME’ was not declared in this scope; did you mean ‘STONEDB_BRANCH_NAME’?
 8134 |       static_cast<int>(sizeof(STONEDB_TAG_NAME)))
      |                               ^~~~~~~~~~~~~~~~
      |                               STONEDB_BRANCH_NAME
make[2]: *** [sql/CMakeFiles/sql.dir/build.make:5247: sql/CMakeFiles/sql.dir/mysqld.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:8269: sql/CMakeFiles/sql.dir/all] Error 2
make: *** [Makefile:161: all] Error 2

Expected behavior

No response

How To Reproduce

No response

Environment

root@ub01:~# /stonedb57/install/bin/mysqld --version
/stonedb57/install/bin/mysqld  Ver 5.7.36-StoneDB-v1.0.2 for Linux on x86_64 (build-)
build information as follow:
        Repository address: https://github.com/stoneatom/stonedb.git:stonedb-5.7-dev
        Branch name: stonedb-5.7-dev
        Last commit ID: 0f4250589
        Last commit time: Date:   Tue Feb 21 06:09:37 2023 +0000
        Build time: Date: Wed Feb 22 17:50:51 CST 2023

Are you interested in submitting a PR to solve the problem?

RingsC commented 1 year ago

Can you acess github? this var comes from git at compiling stage. pls check your dev env. Thanks. @davidshiz

davidshiz commented 1 year ago

Can you acess github? this var comes from git at compiling stage. pls check your dev env. Thanks. @davidshiz I can access github,the reason for this error is personal repo in github have no tag.

RingsC commented 1 year ago

Not a bug, Close it now.

RingsC commented 1 year ago

in CMakeLists.txt

838  EXECUTE_PROCESS(COMMAND bash "-c" "git describe --tags `git rev-list --tags --max-count=1` |head -n 1 |awk -F'-' '{print $2}'"
839                   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
840                   OUTPUT_VARIABLE ER_TAG_NAME)
841  string(STRIP "${ER_TAG_NAME}" ER_TAG_NAME)
842 
843  SET(STONEDB_REPO_ADDR "${ER_REPO_NAME}:${ER_BRANCH_NAME}")
844  SET(STONEDB_BRANCH_NAME "${ER_BRANCH_NAME}")
845  SET(STONEDB_COMMIT_ID "${ER_COMMIT_ID}")
846  SET(STONEDB_COMMIT_TIME "${ER_COMMIT_TIME}")
847  SET(STONEDB_BUILD_TIME "Date: ${ER_BUILD_TIME}")
848  SET(STONEDB_TAG_NAME "${ER_TAG_NAME}")

when you can not get TAG_NAME, we define a TAG_NAME variable with empty value to make sure that cmake will generate this variable properly.

laofan13 commented 1 year ago

Hello, how to solve this error, we have encountered it now

hustjieke commented 1 year ago

@lifengfan13 You can have a try in this way. Just add an empty tag by git command git tag -a ....

laofan13 commented 1 year ago

@lifengfan13 You can have a try in this way. Just add an empty tag by git command git tag -a ....

Thanks, I'll try it

laofan13 commented 1 year ago

hello, I still have a bug.

/stonedb/sql/mysqld.cc: In function ‘void print_build_info()’:
/stonedb/sql/mysqld.cc:7049:33: error: ‘STONEDB_BRANCH_NAME’ was not declared in this scope
 7049 |   printf("\tBranch name: %s\n", STONEDB_BRANCH_NAME);
      |                                 ^~~~~~~~~~~~~~~~~~~
/stonedb/sql/mysqld.cc:7050:36: error: ‘STONEDB_COMMIT_ID’ was not declared in this scope
 7050 |   printf("\tLast commit ID: %s\n", STONEDB_COMMIT_ID);
      |                                    ^~~~~~~~~~~~~~~~~
/stonedb/sql/mysqld.cc:7051:38: error: ‘STONEDB_COMMIT_TIME’ was not declared in this scope; did you mean ‘STONEDB_BUILD_TIME’?
 7051 |   printf("\tLast commit time: %s\n", STONEDB_COMMIT_TIME);
      |                                      ^~~~~~~~~~~~~~~~~~~
      |                                      STONEDB_BUILD_TIME
/stonedb/sql/mysqld.cc: In function ‘void set_server_version()’:
/stonedb/sql/mysqld.cc:8134:31: error: ‘STONEDB_TAG_NAME’ was not declared in this scope
 8134 |       static_cast<int>(sizeof(STONEDB_TAG_NAME)))
hustjieke commented 1 year ago

STONEDB_BRANCH_NAME

Is your env. clean? First time to make build? I'll try to reproduce in my machine.

laofan13 commented 1 year ago

STONEDB_BRANCH_NAME

Is your env. clean? First time to make build? I'll try to reproduce in my machine.

I compiled it for the first time, according to the official website dockers tutorial. The system environment is Ubuntu 2022 x86_64 x86_64 x86_64 GNU/Linux.

davidshiz commented 1 year ago

@lifengfan13 You can change the stonedb/CMakeLists.txt file, line 848 SET(STONEDB_TAG_NAME "${ER_TAG_NAME}") to SET(STONEDB_TAG_NAME "V103"), can temporarily solve this problem

laofan13 commented 1 year ago

Thanks,I'll try .

laofan13 commented 1 year ago

I am git clone repo on the host, and then mount it in docker, so these variables cannot be obtained. must be run command git config --global --add safe.directory /stonedb .

RingsC commented 1 year ago

I am git clone repo on the host, and then mount it in docker, so these variables cannot be obtained. must be run command git config --global --add safe.directory /stonedb .

what result does the following command get on your instance ?

git describe --tags `git rev-list --tags --max-count=1` |head -n 1 |awk -F'-' '{print $2}'
laofan13 commented 1 year ago

I am git clone repo on the host, and then mount it in docker, so these variables cannot be obtained. must be run command git config --global --add safe.directory /stonedb .

what result does the following command get on your instance ?

git describe --tags `git rev-list --tags --max-count=1` |head -n 1 |awk -F'-' '{print $2}'

It has been compiled successfully! Thanks.