Skip to content

Commit

Permalink
refactor: fix compile for mcjit and improve to tests (#3952)
Browse files Browse the repository at this point in the history
* refactor: rm SQL_CASE_BASE_DIR

* fix: compile on mcjit

* feat: setup SqlCaseBaseDir for hybridse

TODO: also setup for tests in src/
  • Loading branch information
aceforeverd authored Jul 25, 2024
1 parent ca7ab42 commit d9d15cd
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 7 deletions.
1 change: 1 addition & 0 deletions hybridse/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ thirdsrc

src/fe_version.h
src/hyhridse_version.h
src/case/test_cfg.h

# ignore docgen
style.xml
Expand Down
6 changes: 6 additions & 0 deletions hybridse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ configure_file(
"${PROJECT_SOURCE_DIR}/src/version.h.in"
"${PROJECT_SOURCE_DIR}/src/hybridse_version.h"
)

configure_file(
"${PROJECT_SOURCE_DIR}/src/case/test_cfg.h.in"
"${PROJECT_SOURCE_DIR}/src/case/test_cfg.h"
)

if (DEFINED ENV{CI})
# suppress useless maven log (e.g download log) on CI environment
set(MAVEN_FLAGS --batch-mode)
Expand Down
3 changes: 3 additions & 0 deletions hybridse/include/case/sql_case.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ class SqlCase {
}
static std::set<std::string> HYBRIDSE_LEVEL();

// Get the base directory searching for yaml test cases.
// It is by default directory to current git repository, or you can override
// the base directory with 'SQL_CASE_BASE_DIR' environment variable
static std::string SqlCaseBaseDir();

static bool IsDebug() {
Expand Down
7 changes: 2 additions & 5 deletions hybridse/src/case/sql_case.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "glog/logging.h"
#include "node/sql_node.h"
#include "plan/plan_api.h"
#include "case/test_cfg.h"
#include "vm/engine.h"
#include "zetasql/parser/parser.h"
#include "planv2/ast_node_converter.h"
Expand Down Expand Up @@ -1762,11 +1763,7 @@ std::string SqlCase::SqlCaseBaseDir() {
if (value != nullptr) {
return std::string(value);
}
value = getenv("YAML_CASE_BASE_DIR");
if (value != nullptr) {
return std::string(value);
}
return "";
return SQL_CASE_BASE_DIR;
}

absl::StatusOr<std::vector<codec::Row>> ExtractInsertRow(vm::HybridSeJitWrapper* jit, absl::string_view insert,
Expand Down
22 changes: 22 additions & 0 deletions hybridse/src/case/test_cfg.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Copyright (c) 2024 OpenMLDB Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef HYBRIDSE_SRC_CASE_TEST_CFG_H_
#define HYBRIDSE_SRC_CASE_TEST_CFG_H_

#define SQL_CASE_BASE_DIR "${CMAKE_SOURCE_DIR}"

#endif // HYBRIDSE_SRC_CASE_TEST_CFG_H_
5 changes: 3 additions & 2 deletions hybridse/src/vm/jit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ extern "C" {
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/Core.h"
#include "llvm/ExecutionEngine/JITEventListener.h"
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
#include "llvm/ExecutionEngine/Orc/IRTransformLayer.h"
Expand Down Expand Up @@ -314,15 +315,15 @@ bool HybridSeMcJitWrapper::AddModule(
} else {
execution_engine_->addModule(std::move(module));
}
if (jit_options_.IsEnableVTune()) {
if (jit_options_.IsEnableVtune()) {
auto listener = ::llvm::JITEventListener::createIntelJITEventListener();
if (listener == nullptr) {
LOG(WARNING) << "Intel jit events is not enabled";
} else {
execution_engine_->RegisterJITEventListener(listener);
}
}
if (jit_options_.IsEnableGDB()) {
if (jit_options_.IsEnableGdb()) {
auto listener =
::llvm::JITEventListener::createGDBRegistrationListener();
if (listener == nullptr) {
Expand Down

0 comments on commit d9d15cd

Please sign in to comment.