From 7b5123edda43d5a51b617e2b069c57766dc155ec Mon Sep 17 00:00:00 2001 From: Arthur Petukhovsky Date: Wed, 31 May 2023 15:06:26 +0000 Subject: [PATCH] Fix elog --- libs/walproposer/.gitignore | 2 ++ libs/walproposer/build.rs | 19 +++++++++---------- libs/walproposer/build.sh | 25 ++++--------------------- libs/walproposer/ext.c | 3 --- libs/walproposer/test.c | 10 ++++++---- 5 files changed, 21 insertions(+), 38 deletions(-) delete mode 100644 libs/walproposer/ext.c diff --git a/libs/walproposer/.gitignore b/libs/walproposer/.gitignore index e69de29bb2..9eca6c88cf 100644 --- a/libs/walproposer/.gitignore +++ b/libs/walproposer/.gitignore @@ -0,0 +1,2 @@ +*.a +*.o diff --git a/libs/walproposer/build.rs b/libs/walproposer/build.rs index e864276d7c..794ea5ad5e 100644 --- a/libs/walproposer/build.rs +++ b/libs/walproposer/build.rs @@ -25,7 +25,6 @@ fn main() -> anyhow::Result<()> { // println!("cargo:rustc-link-lib=pgport_srv"); println!("cargo:rustc-link-arg=-Wl,--start-group"); println!("cargo:rustc-link-arg=-lwalproposer"); - println!("cargo:rustc-link-arg=-lext"); println!("cargo:rustc-link-arg=-lpgport_srv"); println!("cargo:rustc-link-arg=-lpostgres"); println!("cargo:rustc-link-arg=-lpgcommon_srv"); @@ -52,15 +51,15 @@ fn main() -> anyhow::Result<()> { // disable fPIE println!("cargo:rustc-link-arg=-no-pie"); - // if !std::process::Command::new("./build.sh") - // .output() - // .expect("could not spawn `clang`") - // .status - // .success() - // { - // // Panic if the command was not successful. - // panic!("could not compile object file"); - // } + if !std::process::Command::new("./build.sh") + .output() + .expect("could not spawn `clang`") + .status + .success() + { + // Panic if the command was not successful. + panic!("could not compile object file"); + } // println!("cargo:rustc-link-lib=dylib=neon"); // println!("cargo:rustc-link-search=/Users/arthur/zen/zenith/pg_install/build/neon-v15"); diff --git a/libs/walproposer/build.sh b/libs/walproposer/build.sh index 6fa3bf3cf1..af82afe10a 100755 --- a/libs/walproposer/build.sh +++ b/libs/walproposer/build.sh @@ -1,32 +1,15 @@ #!/bin/bash set -e -# cc -c -o walproposer.o \ -# -static \ -# -I /Users/arthur/zen/zenith/pg_install/v15/include/postgresql/server \ -# /Users/arthur/zen/zenith/pgxn/neon/walproposer.c +# TODO: rewrite to Makefile -# cc -shared \ -# -I /Users/arthur/zen/zenith/pg_install/v15/include/postgresql/server \ -# -I /Users/arthur/zen/zenith/pgxn/neon \ -# -L /Users/arthur/zen/zenith/pg_install/build/v15/src/common \ -# -L /Users/arthur/zen/zenith/pg_install/build/v15/src/port \ -# -lpgcommon -lpgport -lz -lreadline -lm \ -# -o walproposer.so walproposer.o - -# clang -c -o walproposer.o walproposer.c -ferror-limit=1 -# ar rcs libwalproposer.a walproposer.o - -make -C ../../ neon-pg-ext-v15 -s -make -C ../../pg_install/build/v15/src/backend postgres-lib -s +# make -C ../../ neon-pg-ext-v15 -s +# make -C ../../pg_install/build/v15/src/backend postgres-lib -s cp ../../pg_install/build/v15/src/backend/libpostgres.a . cp ../../pg_install/build/v15/src/common/libpgcommon_srv.a . cp ../../pg_install/build/v15/src/port/libpgport_srv.a . -cp ../../pg_install/build/v15/src/interfaces/libpq/libpq.a . -# -lseccomp -lssl -lcrypto -lz -lpthread -lrt -ldl -lm - -clang -c -o test.o test.c -ferror-limit=1 -I ../../pg_install/v15/include/postgresql/server +clang -g -c -o test.o test.c -ferror-limit=1 -I ../../pg_install/v15/include/postgresql/server rm -rf libwalproposer.a ar rcs libwalproposer.a test.o diff --git a/libs/walproposer/ext.c b/libs/walproposer/ext.c deleted file mode 100644 index 45e073a10a..0000000000 --- a/libs/walproposer/ext.c +++ /dev/null @@ -1,3 +0,0 @@ -int hohoho(int a, int b) { - return a + b; -} \ No newline at end of file diff --git a/libs/walproposer/test.c b/libs/walproposer/test.c index e146c9ecdc..20086604de 100644 --- a/libs/walproposer/test.c +++ b/libs/walproposer/test.c @@ -2,15 +2,17 @@ #include "rust_bindings.h" #include #include "postgres.h" +#include "utils/memutils.h" // From src/backend/main/main.c const char *progname = "fakepostgres"; -int hohoho(int a, int b); - int TestFunc(int a, int b) { + MemoryContextInit(); + printf("TestFunc: %d + %d = %d\n", a, b, a + b); - // elog(LOG, "postgres elog test"); rust_function(0); - return hohoho(a, b); + elog(LOG, "postgres elog test"); + printf("After rust_function\n"); + return a + b; }