Skip to content

Commit

Permalink
Delay linker resolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
prasannavl committed Jul 27, 2023
1 parent 20e7383 commit f456fd9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
17 changes: 17 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,20 @@
# builds and ad-hoc cargo invocations all
# result in the consistent compilation
target-dir = "./build/lib/target"

rustflags = [
"-C", "link-arg=-z",
"-C", "link-arg=undefs",
]

[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]

[target.aarch64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
2 changes: 1 addition & 1 deletion lib/ain-cpp-imports/src/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub mod ffi {
fn pastChangiIntermediateHeight2() -> bool;
fn pastChangiIntermediateHeight3() -> bool;
fn pastChangiIntermediateHeight4() -> bool;
fn SomethingElse() -> bool;
fn pastChangiIntermediateHeight5() -> bool;
fn CppLogPrintf(message: String);
}
}
5 changes: 3 additions & 2 deletions lib/ain-cpp-imports/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ mod ffi {
pub fn pastChangiIntermediateHeight4() -> bool {
unimplemented!("{}", UNIMPL_MSG)
}
pub fn SomethingElse() -> bool {
pub fn pastChangiIntermediateHeight5() -> bool {
unimplemented!("{}", UNIMPL_MSG)
}

Expand Down Expand Up @@ -160,7 +160,8 @@ pub fn past_changi_intermediate_height_4_height() -> bool {
}

pub fn past_changi_intermediate_height_5_height() -> bool {
ffi::SomethingElse()
const CHANGI_5_HEIGHT: i32 = 0;
ffi::getCurrentHeight() > CHANGI_5_HEIGHT
}

pub fn log_print(message: &str) {
Expand Down
3 changes: 2 additions & 1 deletion src/ffi/ffiexports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,9 @@ bool pastChangiIntermediateHeight4() {
return ::ChainActive().Height() >= Params().GetConsensus().ChangiIntermediateHeight4;
}

bool SomethingElse() {
bool pastChangiIntermediateHeight5() {
LOCK(cs_main);
return ::ChainActive().Height() >= Params().GetConsensus().ChangiIntermediateHeight5;
}


2 changes: 1 addition & 1 deletion src/ffi/ffiexports.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ int getCurrentHeight();
bool pastChangiIntermediateHeight2();
bool pastChangiIntermediateHeight3();
bool pastChangiIntermediateHeight4();
bool SomethingElse();
bool pastChangiIntermediateHeight5();
void CppLogPrintf(rust::string message);

#endif // DEFI_FFI_FFIEXPORTS_H

0 comments on commit f456fd9

Please sign in to comment.