Fix lib.h falling back to TARGET_LINUX during wasm_module and c module compilation
This commit is contained in:
+7
-6
@@ -265,14 +265,15 @@ sub compile_wasm_module {
|
||||
my ( $srcs, $inc ) = Util::find_tacle_sources($module);
|
||||
Util::run(
|
||||
"$wasi_root/bin/clang", @wasi_cflags,
|
||||
"-Dmain=tacle_main_bullshit", "-I$inc",
|
||||
"targets/wasm-module/$module.cpp", @$srcs,
|
||||
'-o', "$bd/wasm_module.wasm"
|
||||
"-Dmain=tacle_main_bullshit", "-DTARGET_WASM",
|
||||
"-I$inc", "targets/wasm-module/$module.cpp",
|
||||
@$srcs, '-o',
|
||||
"$bd/wasm_module.wasm"
|
||||
);
|
||||
}
|
||||
else {
|
||||
Util::run( "$wasi_root/bin/clang", @wasi_cflags,
|
||||
"targets/wasm-module/$module.cpp",
|
||||
"-DTARGET_WASM", "targets/wasm-module/$module.cpp",
|
||||
'-o', "$bd/wasm_module.wasm" );
|
||||
|
||||
}
|
||||
@@ -372,8 +373,8 @@ sub compile_c_module {
|
||||
my ( $module, $bd, $target ) = @_;
|
||||
my ( $cc, @flags ) =
|
||||
( $target eq 'linux' )
|
||||
? ( $linux_cc, @linux_cflags )
|
||||
: ( $cross_cc, @cross_cflags );
|
||||
? ( $linux_cc, @linux_cflags, '-DTARGET_LINUX' )
|
||||
: ( $cross_cc, @cross_cflags, '-DTARGET_FAIL' );
|
||||
|
||||
if ( Util::module_is_tacle($module) ) {
|
||||
my ( $srcs, $inc ) = Util::find_tacle_sources($module);
|
||||
|
||||
+11
-6
@@ -10,17 +10,23 @@
|
||||
#define IMPORT(fnct) __attribute__((import_module("env"), import_name(fnct)))
|
||||
|
||||
#if !defined(TARGET_FAIL) && !defined(TARGET_LINUX_BAREMETAL) && \
|
||||
!defined(TARGET_LINUX)
|
||||
!defined(TARGET_LINUX) && !defined(TARGET_WASM)
|
||||
// Set to linux while editing to prevent lsp errors
|
||||
#define TARGET_LINUX
|
||||
#endif
|
||||
|
||||
// Both the wasm wrapper and the wasm module use lib.h
|
||||
// TARGET_WASM is for the wasm module...
|
||||
#ifdef TARGET_WASM
|
||||
#define PRINT(fmt, ...) print(fmt)
|
||||
#endif
|
||||
|
||||
// ...the rest is for the wasm wrapper
|
||||
#ifdef TARGET_FAIL
|
||||
#define MAIN void os_main(void)
|
||||
#define PRINT(fmt, ...)
|
||||
#define PRINT_ERROR(fmt, ...)
|
||||
#define PRINT_SUCCESS(fmt, ...)
|
||||
#define HOST_PRINT(msg)
|
||||
#define RET(val) return
|
||||
#endif
|
||||
|
||||
@@ -29,11 +35,11 @@
|
||||
#define PRINT(fmt, ...)
|
||||
#define PRINT_ERROR(fmt, ...)
|
||||
#define PRINT_SUCCESS(fmt, ...)
|
||||
#define HOST_PRINT(msg)
|
||||
#define RET(val) return
|
||||
#define RET(val) return val
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_LINUX
|
||||
#include "stdio.h"
|
||||
#define MAIN int main(int argc, char *argv[])
|
||||
#define PRINT(fmt, ...) fprintf(stdout, fmt, ##__VA_ARGS__)
|
||||
#define PRINT_ERROR(fmt, ...) \
|
||||
@@ -42,8 +48,7 @@
|
||||
#define PRINT_SUCCESS(fmt, ...) \
|
||||
fprintf(stdout, "[Success] "); \
|
||||
fprintf(stdout, fmt, ##__VA_ARGS__)
|
||||
#define HOST_PRINT(msg) print(msg)
|
||||
#define RET(val) return val;
|
||||
#define RET(val) return val
|
||||
#endif
|
||||
|
||||
typedef uint16_t enc_t;
|
||||
|
||||
@@ -52,11 +52,11 @@ extern "C" EXPORT("wasm_module") int wasm_module(void) {
|
||||
};
|
||||
|
||||
if (cmp(Calculated, Expected)) {
|
||||
HOST_PRINT("result correct.\n");
|
||||
PRINT("result correct.\n");
|
||||
fail_marker_positive();
|
||||
return 0;
|
||||
} else {
|
||||
HOST_PRINT("result incorrect.\n");
|
||||
PRINT("result incorrect.\n");
|
||||
fail_marker_negative();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ extern "C" EXPORT("wasm_module") int wasm_module(void) {
|
||||
fail_stop_trace();
|
||||
|
||||
if (X == 5) {
|
||||
HOST_PRINT("result correct.\n");
|
||||
PRINT("result correct.\n");
|
||||
fail_marker_positive();
|
||||
return 0;
|
||||
} else {
|
||||
HOST_PRINT("result incorrect.\n");
|
||||
PRINT("result incorrect.\n");
|
||||
fail_marker_negative();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ static void naive_vote(void) {
|
||||
} else if (YC == ZC) {
|
||||
vote_res = YC;
|
||||
} else {
|
||||
HOST_PRINT("all replicas differ.\n");
|
||||
PRINT("all replicas differ.\n");
|
||||
fail_marker_detected();
|
||||
}
|
||||
}
|
||||
@@ -50,11 +50,11 @@ extern "C" EXPORT("wasm_module") int wasm_module(void) {
|
||||
fail_stop_trace();
|
||||
|
||||
if (vote_res == 5) {
|
||||
HOST_PRINT("vote success.\n");
|
||||
PRINT("vote success.\n");
|
||||
fail_marker_positive();
|
||||
return 0;
|
||||
} else {
|
||||
HOST_PRINT("undetected error.\n");
|
||||
PRINT("undetected error.\n");
|
||||
fail_marker_negative();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ static enc_t sum_out[REPLICA_COUNT];
|
||||
|
||||
static INLINE enc_t apply(enc_t vc, sign_t bdyn) {
|
||||
if (bdyn > SIG_MAX) {
|
||||
HOST_PRINT("signature overflow.\n");
|
||||
PRINT("signature overflow.\n");
|
||||
fail_marker_detected();
|
||||
}
|
||||
return vc + bdyn;
|
||||
@@ -49,7 +49,7 @@ static sign_t cored_vote(void) {
|
||||
cored_res = apply(XC, (XC - ZC));
|
||||
return SIG_s_XZ;
|
||||
} else {
|
||||
HOST_PRINT("all replicas differ.\n");
|
||||
PRINT("all replicas differ.\n");
|
||||
fail_marker_detected();
|
||||
return 0;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ extern "C" EXPORT("wasm_module") int wasm_module(void) {
|
||||
vote_result_sig = SIG_Y;
|
||||
break;
|
||||
default:
|
||||
HOST_PRINT("unknown static_sig.\n");
|
||||
PRINT("unknown static_sig.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -102,18 +102,18 @@ extern "C" EXPORT("wasm_module") int wasm_module(void) {
|
||||
|
||||
/* Validate Vote result */
|
||||
if (!check(cored_res, THE_A, vote_result_sig)) {
|
||||
HOST_PRINT("voted result invalid.\n");
|
||||
PRINT("voted result invalid.\n");
|
||||
fail_marker_detected();
|
||||
return 2;
|
||||
}
|
||||
|
||||
plain_t res = decode(cored_res, THE_A, vote_result_sig);
|
||||
if (res == 5) {
|
||||
HOST_PRINT("cored success.\n");
|
||||
PRINT("cored success.\n");
|
||||
fail_marker_positive();
|
||||
return 0;
|
||||
} else {
|
||||
HOST_PRINT("undetected error.\n");
|
||||
PRINT("undetected error.\n");
|
||||
fail_marker_negative();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ static void naive_vote(void) {
|
||||
} else if (YC == ZC) {
|
||||
vote_res = YC;
|
||||
} else {
|
||||
HOST_PRINT("all replicas differ.\n");
|
||||
PRINT("all replicas differ.\n");
|
||||
fail_marker_detected();
|
||||
}
|
||||
}
|
||||
@@ -50,11 +50,11 @@ extern "C" EXPORT("wasm_module") int wasm_module(void) {
|
||||
fail_stop_trace();
|
||||
|
||||
if (vote_res == 5) {
|
||||
HOST_PRINT("vote success.\n");
|
||||
PRINT("vote success.\n");
|
||||
fail_marker_positive();
|
||||
return 0;
|
||||
} else {
|
||||
HOST_PRINT("undetected error.\n");
|
||||
PRINT("undetected error.\n");
|
||||
fail_marker_negative();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ static enc_t sum_out[REPLICA_COUNT];
|
||||
|
||||
static INLINE enc_t apply(enc_t vc, sign_t bdyn) {
|
||||
if (bdyn > SIG_MAX) {
|
||||
HOST_PRINT("signature overflow.\n");
|
||||
PRINT("signature overflow.\n");
|
||||
fail_marker_detected();
|
||||
}
|
||||
return vc + bdyn;
|
||||
@@ -49,7 +49,7 @@ static sign_t cored_vote(void) {
|
||||
cored_res = apply(XC, (XC - ZC));
|
||||
return SIG_s_XZ;
|
||||
} else {
|
||||
HOST_PRINT("all replicas differ.\n");
|
||||
PRINT("all replicas differ.\n");
|
||||
fail_marker_detected();
|
||||
return 0;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ extern "C" EXPORT("wasm_module") int wasm_module(void) {
|
||||
vote_result_sig = SIG_Y;
|
||||
break;
|
||||
default:
|
||||
HOST_PRINT("unknown static_sig.\n");
|
||||
PRINT("unknown static_sig.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -102,18 +102,18 @@ extern "C" EXPORT("wasm_module") int wasm_module(void) {
|
||||
|
||||
/* Validate Vote result */
|
||||
if (!check(cored_res, THE_A, vote_result_sig)) {
|
||||
HOST_PRINT("voted result invalid.\n");
|
||||
PRINT("voted result invalid.\n");
|
||||
fail_marker_detected();
|
||||
return 2;
|
||||
}
|
||||
|
||||
plain_t res = decode(cored_res, THE_A, vote_result_sig);
|
||||
if (res == 5) {
|
||||
HOST_PRINT("cored success.\n");
|
||||
PRINT("cored success.\n");
|
||||
fail_marker_positive();
|
||||
return 0;
|
||||
} else {
|
||||
HOST_PRINT("undetected error.\n");
|
||||
PRINT("undetected error.\n");
|
||||
fail_marker_negative();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -16,8 +16,10 @@ EXPORT("wasm_module") int wasm_module(void) {
|
||||
|
||||
int ret = binarysearch_return() - (-1);
|
||||
if (ret == 0) {
|
||||
PRINT("result correct.\n");
|
||||
fail_marker_positive();
|
||||
} else {
|
||||
PRINT("result incorrect.\n");
|
||||
fail_marker_negative();
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -16,8 +16,10 @@ EXPORT("wasm_module") int wasm_module(void) {
|
||||
|
||||
int ret = bsort_return();
|
||||
if (ret == 0) {
|
||||
PRINT("result correct.\n");
|
||||
fail_marker_positive();
|
||||
} else {
|
||||
PRINT("result incorrect.\n");
|
||||
fail_marker_negative();
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -16,8 +16,10 @@ EXPORT("wasm_module") int wasm_module(void) {
|
||||
|
||||
int ret = complex_updates_return();
|
||||
if (ret == 0) {
|
||||
PRINT("result correct.\n");
|
||||
fail_marker_positive();
|
||||
} else {
|
||||
PRINT("result incorrect.\n");
|
||||
fail_marker_negative();
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -16,8 +16,10 @@ EXPORT("wasm_module") int wasm_module(void) {
|
||||
|
||||
int ret = countnegative_return();
|
||||
if (ret == 0) {
|
||||
PRINT("result correct.\n");
|
||||
fail_marker_positive();
|
||||
} else {
|
||||
PRINT("result incorrect.\n");
|
||||
fail_marker_negative();
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -16,8 +16,10 @@ EXPORT("wasm_module") int wasm_module(void) {
|
||||
|
||||
int ret = fft_return();
|
||||
if (ret == 0) {
|
||||
PRINT("result correct.\n");
|
||||
fail_marker_positive();
|
||||
} else {
|
||||
PRINT("result incorrect.\n");
|
||||
fail_marker_negative();
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -16,8 +16,10 @@ EXPORT("wasm_module") int wasm_module(void) {
|
||||
|
||||
int ret = matrix1_return();
|
||||
if (ret == 0) {
|
||||
PRINT("result correct.\n");
|
||||
fail_marker_positive();
|
||||
} else {
|
||||
PRINT("result incorrect.\n");
|
||||
fail_marker_negative();
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -16,8 +16,10 @@ EXPORT("wasm_module") int wasm_module(void) {
|
||||
|
||||
int ret = md5_return();
|
||||
if (ret == 0) {
|
||||
PRINT("result correct.\n");
|
||||
fail_marker_positive();
|
||||
} else {
|
||||
PRINT("result incorrect.\n");
|
||||
fail_marker_negative();
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -16,8 +16,10 @@ EXPORT("wasm_module") int wasm_module(void) {
|
||||
|
||||
int ret = (quicksort_return() - 1527923179 != 0);
|
||||
if (ret == 0) {
|
||||
PRINT("result correct.\n");
|
||||
fail_marker_positive();
|
||||
} else {
|
||||
PRINT("result incorrect.\n");
|
||||
fail_marker_negative();
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -16,8 +16,10 @@ EXPORT("wasm_module") int wasm_module(void) {
|
||||
|
||||
int ret = recursion_return();
|
||||
if (ret == 0) {
|
||||
PRINT("result correct.\n");
|
||||
fail_marker_positive();
|
||||
} else {
|
||||
PRINT("result incorrect.\n");
|
||||
fail_marker_negative();
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -16,8 +16,10 @@ EXPORT("wasm_module") int wasm_module(void) {
|
||||
|
||||
int ret = sha_return();
|
||||
if (ret == 0) {
|
||||
PRINT("result correct.\n");
|
||||
fail_marker_positive();
|
||||
} else {
|
||||
PRINT("result incorrect.\n");
|
||||
fail_marker_negative();
|
||||
}
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user