Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
picodata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
picodata
Commits
7362b566
Commit
7362b566
authored
2 years ago
by
Georgy Moshkin
Committed by
Georgy Moshkin
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
build: export symbols explicitly from generated code
parent
37e7fa28
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!482
build: export symbols explicitly from generated code
Pipeline
#16847
passed
1 year ago
Stage: test
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
build.rs
+45
-8
45 additions, 8 deletions
build.rs
src/main.rs
+3
-0
3 additions, 0 deletions
src/main.rs
with
48 additions
and
8 deletions
build.rs
+
45
−
8
View file @
7362b566
use
std
::
collections
::
HashSet
;
use
std
::
io
::
Write
;
use
std
::
panic
::
Location
;
use
std
::
path
::
Path
;
use
std
::
process
::
Command
;
...
...
@@ -34,18 +36,11 @@ fn main() {
std
::
env
::
set_var
(
"MAKEFLAGS"
,
makeflags
);
}
if
cfg!
(
target_os
=
"macos"
)
{
// We don't want to strip unused symbols from the static libraries on
// the linking stage. This leads to problems with tarantool's `crypto`
// module (some symbols are used only by the ffi calls inside `crypto.lua`
// file and we are in trouble if they are stripped by the linker).
rustc
::
link_arg
(
"-C link-dead-code=on"
);
}
for
(
var
,
value
)
in
std
::
env
::
vars
()
{
println!
(
"[{}:{}] {var}={value}"
,
file!
(),
line!
());
}
generate_export_stubs
(
&
out_dir
);
build_tarantool
(
build_root
);
build_http
(
build_root
);
...
...
@@ -53,6 +48,46 @@ fn main() {
println!
(
"cargo:rerun-if-changed=http/http"
);
}
fn
generate_export_stubs
(
out_dir
:
&
str
)
{
let
mut
symbols
=
HashSet
::
with_capacity
(
1024
);
let
exports
=
std
::
fs
::
read_to_string
(
"tarantool-sys/extra/exports"
)
.unwrap
();
read_symbols_into
(
&
exports
,
&
mut
symbols
);
let
exports
=
std
::
fs
::
read_to_string
(
"tarantool-sys/extra/exports_libcurl"
)
.unwrap
();
read_symbols_into
(
&
exports
,
&
mut
symbols
);
let
mut
code
=
Vec
::
with_capacity
(
2048
);
writeln!
(
code
,
"pub fn export_symbols() {{"
)
.unwrap
();
writeln!
(
code
,
" extern
\"
C
\"
{{"
)
.unwrap
();
for
symbol
in
&
symbols
{
writeln!
(
code
,
" static {symbol}: *const ();"
)
.unwrap
();
}
writeln!
(
code
,
" }}"
)
.unwrap
();
// TODO: use std::hint::black_box, when we move to rust 1.66
writeln!
(
code
,
" fn black_box(_: *const ()) {{}}"
)
.unwrap
();
writeln!
(
code
,
" unsafe {{"
)
.unwrap
();
for
symbol
in
&
symbols
{
writeln!
(
code
,
" black_box({symbol});"
)
.unwrap
();
}
writeln!
(
code
,
" }}"
)
.unwrap
();
writeln!
(
code
,
"}}"
)
.unwrap
();
let
gen_path
=
std
::
path
::
Path
::
new
(
out_dir
)
.join
(
"export_symbols.rs"
);
std
::
fs
::
write
(
gen_path
,
code
)
.unwrap
();
fn
read_symbols_into
<
'a
>
(
file_contents
:
&
'a
str
,
symbols
:
&
mut
HashSet
<&
'a
str
>
)
{
for
line
in
file_contents
.lines
()
{
let
line
=
line
.trim
();
if
line
.starts_with
(
'#'
)
{
continue
;
}
if
line
.is_empty
()
{
continue
;
}
symbols
.insert
(
line
);
}
}
}
fn
build_http
(
build_root
:
&
Path
)
{
let
build_dir
=
build_root
.join
(
"tarantool-http"
);
let
build_dir_str
=
build_dir
.display
()
.to_string
();
...
...
@@ -173,9 +208,11 @@ fn build_tarantool(build_root: &Path) {
rustc
::
link_lib_static
(
"shutdown"
);
rustc
::
link_lib_static
(
"swim_udp"
);
rustc
::
link_lib_static
(
"swim_ev"
);
rustc
::
link_lib_static
(
"symbols"
);
rustc
::
link_lib_static
(
"cpu_feature"
);
rustc
::
link_lib_static
(
"luajit"
);
rustc
::
link_lib_static
(
"yaml_static"
);
rustc
::
link_lib_static
(
"xxhash"
);
if
cfg!
(
target_os
=
"macos"
)
{
// OpenMP and Libunwind are builtin to the compiler on macos
...
...
This diff is collapsed.
Click to expand it.
src/main.rs
+
3
−
0
View file @
7362b566
...
...
@@ -10,9 +10,12 @@ use picodata::Entrypoint;
use
picodata
::
IpcMessage
;
use
tarantool
::
fiber
;
include!
(
concat!
(
env!
(
"OUT_DIR"
),
"/export_symbols.rs"
));
mod
test
;
fn
main
()
->
!
{
export_symbols
();
match
args
::
Picodata
::
parse
()
{
args
::
Picodata
::
Run
(
args
)
=>
main_run
(
args
),
args
::
Picodata
::
Test
(
args
)
=>
test
::
main_test
(
args
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment