-
-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support a pgx extension compiling with no_std (#385)
* support a pgx extension compiling with no_std * fix some compilation issues * cleanups * support a pgx extension compiling with no_std * fix some compilation issues * cleanups * fix compilation problem
- Loading branch information
1 parent
a0cf135
commit 10e133e
Showing
28 changed files
with
274 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Auto-generated by pgx. You may edit this, or delete it to have a new one created. | ||
|
||
[target.x86_64-unknown-linux-gnu] | ||
linker = "./.cargo/pgx-linker-script.sh" | ||
|
||
[target.aarch64-unknown-linux-gnu] | ||
linker = "./.cargo/pgx-linker-script.sh" | ||
|
||
[target.x86_64-apple-darwin] | ||
linker = "./.cargo/pgx-linker-script.sh" | ||
|
||
[target.aarch64-apple-darwin] | ||
linker = "./.cargo/pgx-linker-script.sh" | ||
|
||
[target.x86_64-unknown-freebsd] | ||
linker = "./.cargo/pgx-linker-script.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#! /usr/bin/env bash | ||
# Auto-generated by pgx. You may edit this, or delete it to have a new one created. | ||
|
||
if [[ $CARGO_BIN_NAME == "sql-generator" ]]; then | ||
UNAME=$(uname) | ||
if [[ $UNAME == "Darwin" ]]; then | ||
TEMP=$(mktemp pgx-XXX) | ||
echo "*_pgx_internals_*" > ${TEMP} | ||
gcc -exported_symbols_list ${TEMP} $@ | ||
rm -rf ${TEMP} | ||
else | ||
TEMP=$(mktemp pgx-XXX) | ||
echo "{ __pgx_internals_*; };" > ${TEMP} | ||
gcc -Wl,-dynamic-list=${TEMP} $@ | ||
rm -rf ${TEMP} | ||
fi | ||
else | ||
gcc -Wl,-undefined,dynamic_lookup $@ | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.DS_Store | ||
.idea/ | ||
/target | ||
*.iml | ||
**/*.rs.bk | ||
Cargo.lock | ||
sql/nostd-1.0.sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[package] | ||
name = "nostd" | ||
version = "0.0.0" | ||
edition = "2018" | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
# remove this empty 'workspace' declaration if compiling outside of 'pgx' | ||
[workspace] | ||
|
||
[features] | ||
default = ["pg13"] | ||
pg10 = ["pgx/pg10", "pgx-tests/pg10" ] | ||
pg11 = ["pgx/pg11", "pgx-tests/pg11" ] | ||
pg12 = ["pgx/pg12", "pgx-tests/pg12" ] | ||
pg13 = ["pgx/pg13", "pgx-tests/pg13" ] | ||
pg14 = ["pgx/pg14", "pgx-tests/pg14" ] | ||
pg_test = [] | ||
|
||
[dependencies] | ||
pgx = { path = "../../../pgx/pgx/", default-features = false } | ||
serde = "1.0.114" | ||
|
||
[dev-dependencies] | ||
pgx-tests = { path = "../../../pgx/pgx-tests" } | ||
|
||
# uncomment these if compiling outside of 'pgx' | ||
# [profile.dev] | ||
# panic = "unwind" | ||
# lto = "thin" | ||
|
||
# [profile.release] | ||
# panic = "unwind" | ||
# opt-level = 3 | ||
# lto = "fat" | ||
# codegen-units = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
comment = 'nostd: Created by pgx' | ||
default_version = '1.0' | ||
module_pathname = '$libdir/nostd' | ||
relocatable = false | ||
superuser = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/* Auto-generated by pgx. You may edit this, or delete it to have a new one created. */ | ||
pgx::pg_binary_magic!(nostd); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
//! This exists just to make sure we can compile various things under `#![no_std]` | ||
#![no_std] | ||
extern crate alloc; | ||
|
||
use pgx::*; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use alloc::string::String; | ||
|
||
pg_module_magic!(); | ||
|
||
/// standard Rust equality/comparison derives | ||
#[derive(Eq, PartialEq, Ord, Hash, PartialOrd)] | ||
|
||
/// Support using this struct as a Postgres type, which the easy way requires Serde | ||
#[derive(PostgresType, Serialize, Deserialize)] | ||
|
||
/// automatically generate =, <> SQL operator functions | ||
#[derive(PostgresEq)] | ||
|
||
/// automatically generate <, >, <=, >=, and a "_cmp" SQL functions | ||
/// When "PostgresEq" is also derived, pgx also creates an "opclass" (and family) | ||
/// so that the type can be used in indexes `USING btree` | ||
#[derive(PostgresOrd)] | ||
|
||
/// automatically generate a "_hash" function, and the necessary "opclass" (and family) | ||
/// so the type can also be used in indexes `USING hash` | ||
#[derive(PostgresHash)] | ||
pub struct Thing(String); | ||
|
||
#[derive(PostgresType, Serialize, Deserialize, Eq, PartialEq)] | ||
pub struct MyType { | ||
value: i32, | ||
} | ||
|
||
#[pg_operator] | ||
#[opname(=)] | ||
fn my_eq(left: MyType, right: MyType) -> bool { | ||
left == right | ||
} | ||
|
||
#[pg_extern] | ||
fn hello_nostd() -> &'static str { | ||
"Hello, nostd" | ||
} | ||
|
||
#[pg_extern] | ||
fn echo(input: String) -> String { | ||
input | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.