Skip to content

Commit

Permalink
[GAIA-IR] Make v6d_ffi build as features in IR (#1775)
Browse files Browse the repository at this point in the history
* make v6d_ffi build as features in IR
* Add link flags to handle unresolved symbols of vineyard deps
* Requires 'native' when building executor

Co-authored-by: Tao He <sighingnow@gmail.com>
  • Loading branch information
BingqingLyu and sighingnow committed Jun 29, 2022
1 parent 9abea6d commit b7960ba
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 14 deletions.
5 changes: 3 additions & 2 deletions interactive_engine/executor/gaia_runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ log4rs = "0.8.0"
maxgraph-common = { path = "../../rust-common" }
maxgraph-store = { path = "../store" }
maxgraph-server = { path = "../server" }
maxgraph-runtime = { path = "../runtime" }
maxgraph-runtime = { path = "../runtime", features = ["with_native"] }
protobuf = { version = "~2.0", features = ["with-bytes"] }
rand = "0.7.3"
regex = "1"
Expand All @@ -43,10 +43,11 @@ gaia_pegasus = { path = "../../../research/engine/pegasus/pegasus", package = "p
pegasus_network = { path = "../../../research/engine/pegasus/network" }
pegasus_server = { path = "../../../research/engine/pegasus/server" }
runtime_integration = { path = "../../../research/query_service/ir/integrated" }
v6d_ffi = { path = "../../../research/query_service/ir/v6d_ffi" }
v6d_ffi = { path = "../../../research/query_service/ir/v6d_ffi", features = ["with_v6d"] }

[dev-dependencies]
env_logger = "0.6"

[build-dependencies]
cmake = "0.1"

4 changes: 4 additions & 0 deletions interactive_engine/executor/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ env_logger = "0.6"

[build-dependencies]
cmake = "0.1"

[features]
default = []
with_native = []
35 changes: 25 additions & 10 deletions interactive_engine/executor/runtime/build.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//
//! Copyright 2020 Alibaba Group Holding Limited.
//!
//!
//! 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.
Expand All @@ -15,14 +15,21 @@

extern crate cmake;

use std::env;
use std::path::Path;

use cmake::Config;
use std::env;

fn main() {
let dst = Config::new("native")
.build_target("native_store")
.build();
fn main() -> Result<(), Box<dyn std::error::Error>> {
codegen_inplace()
}

#[cfg(feature = "with_native")]
const NATIVE_DIR: &'static str = "native";

#[cfg(feature = "with_native")]
fn codegen_inplace() -> Result<(), Box<dyn std::error::Error>> {
let dst = Config::new(NATIVE_DIR).build_target("native_store").build();

println!("cargo:rustc-link-search=/usr/local/lib");
println!("cargo:rustc-link-search=/usr/local/lib64");
Expand All @@ -32,7 +39,7 @@ fn main() {
println!("cargo:rustc-link-search={}/lib", val);
println!("cargo:rustc-link-search={}/lib64", val);
}
Err(_) => ()
Err(_) => (),
}
println!("cargo:rustc-link-search={}/build", dst.display());
println!("cargo:rustc-link-lib=native_store");
Expand All @@ -50,7 +57,15 @@ fn main() {
if Path::new("/usr/ali/alicpp/built/gcc-4.9.2").exists() {
println!("cargo:cfg=tunnel");
}
} else if cfg!(target_os = "macos") {} else {
} else if cfg!(target_os = "macos") {
} else {
unimplemented!()
}

Ok(())
}

#[cfg(not(feature = "with_native"))]
fn codegen_inplace() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}
26 changes: 26 additions & 0 deletions research/query_service/ir/integrated/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
//! Copyright 2020-2022 Alibaba Group Holding Limited.
//!
//! 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.

fn main() -> Result<(), Box<dyn std::error::Error>> {
if cfg!(target_os = "linux") {
println!("cargo:rustc-link-arg=-Wl,--unresolved-symbols=ignore-all");
} else if cfg!(target_os = "macos") {
println!("cargo:rustc-link-arg=-Wl,-undefined");
println!("cargo:rustc-link-arg=-Wl,dynamic_lookup");
} else {
unimplemented!()
}
Ok(())
}
4 changes: 4 additions & 0 deletions research/query_service/ir/v6d_ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ maxgraph-runtime = {path = "../../../../interactive_engine/executor/runtime"}

[build-dependencies]
cmake = "0.1"

[features]
default = []
with_v6d = []
19 changes: 17 additions & 2 deletions research/query_service/ir/v6d_ffi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@ use std::path::Path;

use cmake::Config;

fn main() {
let dst = Config::new("src/native")
fn main() -> Result<(), Box<dyn std::error::Error>> {
codegen_inplace()
}

#[cfg(feature = "with_v6d")]
const NATIVE_DIR: &'static str = "src/native";

#[cfg(feature = "with_v6d")]
fn codegen_inplace() -> Result<(), Box<dyn std::error::Error>> {
let dst = Config::new(NATIVE_DIR)
.build_target("v6d_native_store")
.build();

Expand Down Expand Up @@ -55,4 +63,11 @@ fn main() {
} else {
unimplemented!()
}

Ok(())
}

#[cfg(not(feature = "with_v6d"))]
fn codegen_inplace() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

0 comments on commit b7960ba

Please sign in to comment.