-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Platform support and auto
scripts improvements
#124
base: master
Are you sure you want to change the base?
Conversation
Sound good.
I believe we are in the early days of the project. The project is still experimental. |
ee02bb9
to
5cb033e
Compare
`std::fs::canonicalize` always converts paths to UNC on Windows. However, a plenty of software lacks support for this naming convention, notably Microsoft's C/C++ Compiler. `dunce::canonicalize` is a commonly used solution that picks the most compatible path representation on Windows and calls `fs::canonicalize` on any other platform.
Previously, we assumed that the source directory is a parent of `NGX_OBJS`. This isn't true, `--builddir` can point to an absolute path, and source directory can be read-only. Specifying an explicit source path and resolving includes agains it fixes the build for such configurations.
The `NGX_OBJS` name was taken from the nginx buildsystem, but it is an internal detail there, so the name wasn't really meaningful. Now that we have `NGINX_SOURCE_DIR`, there's a benefit in more consistent naming. Technically, not a breaking change, as we haven't had a release with the old variable name.
e6426f9
to
f8bff78
Compare
if [ "$NGX_DEBUG" = YES ]; then | ||
ngx_cargo_default_profile=ngx-debug | ||
else | ||
ngx_cargo_default_profile=ngx-release |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When building without --with-debug
I get
...
objs/ngx_modules.o \
-L/media/psf/workspace/nginx/nginScript/quickjs-ng/build -lpthread -lcrypt objs/ngx_rust_examples/ngx-release/examples/libawssig.a -lm objs/ngx_ru
st_examples/ngx-release/examples/libcurl.a objs/ngx_rust_examples/ngx-release/examples/libupstream.a objs/ngx_rust_examples/ngx-release/examples/l
ibhttporigdst.a -lpcre2-8 -lssl -lcrypto -lpthread -lz \
-Wl,-E
/usr/bin/ld: objs/ngx_rust_examples/ngx-release/examples/libcurl.a(curl-de3e6fe882b906f0.core-f5a882967048065e.core.ecb3f420ec5f4bcf-cgu.0.rcgu.o.
rcgu.o): in function `core::num::from_str_radix_panic_rt':
/rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/num/mod.rs:1399: multiple definition of `core::num::from_str_radix_panic_rt'; obj
s/ngx_rust_examples/ngx-release/examples/libawssig.a(awssig-22b3aae1e52dce40.core-f5a882967048065e.core.ecb3f420ec5f4bcf-cgu.0.rcgu.o.rcgu.o):/rus
tc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/num/mod.rs:1399: first defined here
/usr/bin/ld: objs/ngx_rust_examples/ngx-release/examples/libcurl.a(curl-de3e6fe882b906f0.core-f5a882967048065e.core.ecb3f420ec5f4bcf-cgu.0.rcgu.o.
rcgu.o): in function `...
u.0.rcgu.o.rcgu.o): in function `core::fmt::num::<impl core::fmt::LowerHex for i8>::fmt':
/usr/bin/ld: objs/ngx_rust_examples/ngx-release/examples/libcurl.a(curl-de3e6fe882b906f0.core-f5a882967048065e.core.ecb3f420ec5f4bcf-cgu.0.rcgu.o.
rcgu.o): in function `core::fmt::num::<impl core::fmt::UpperHex for i8>::fmt':
/rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/fmt/num.rs:155: multiple definition of `core::fmt::num::<impl core::fmt::UpperHex
for u8>::fmt'; objs/ngx_rust_examples/ngx-release/examples/libawssig.a(awssig-22b3aae1e52dce40.core-f5a882967048065e.core.ecb3f420ec5f4bcf-cgu.0.
rcgu.o.rcgu.o):/rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/fmt/num.rs:155: first defined here
/usr/bin/ld: objs/ngx_rust_examples/ngx-release/examples/libcurl.a(curl-de3e6fe882b906f0.core-f5a882967048065e.core.ecb3f420ec5f4bcf-cgu.0.rcgu.o.
rcgu.o): in function `core::fmt::num::imp::<impl core::fmt::Display for u64>::fmt':
/rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/fmt/num.rs:313: multiple definition of `core::fmt::num::imp::<impl core::fmt::Dis
play for usize>::fmt'; objs/ngx_rust_examples/ngx-release/examples/libawssig.a(awssig-22b3aae1e52dce40.core-f5a882967048065e.core.ecb3f420ec5f4bcf
-cgu.0.rcgu.o.rcgu.o):/rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/fmt/num.rs:313: first defined here
/usr/bin/ld: objs/ngx_rust_examples/ngx-release/examples/libcurl.a(curl-de3e6fe882b906f0.core-f5a882967048065e.core.ecb3f420ec5f4bcf-cgu.0.rcgu.o.
rcgu.o): in function `core::fmt::Formatter::write_str':
/rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/fmt/mod.rs:1625: multiple definition of `<core::fmt::Formatter as core::fmt::Writ
e>::write_str'; objs/ngx_rust_examples/ngx-release/examples/libawssig.a(awssig-22b3aae1e52dce40.core-f5a882967048065e.core.ecb3f420ec5f4bcf-cgu.0.
rcgu.o.rcgu.o):/rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/fmt/mod.rs:1625: first defined here
/usr/bin/ld: objs/ngx_rust_examples/ngx-release/examples/libcurl.a(curl-de3e6fe882b906f0.core-f5a882967048065e.core.ecb3f420ec5f4bcf-cgu.0.rcgu.o.
rcgu.o): in function `core::fmt::num::<impl core::fmt::LowerHex for i64>::fmt':
/rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/fmt/num.rs:155: multiple definition of `core::fmt::num::<impl core::fmt::LowerHex
for usize>::fmt'; objs/ngx_rust_examples/ngx-release/examples/libawssig.a(awssig-22b3aae1e52dce40.core-f5a882967048065e.core.ecb3f420ec5f4bcf-cgu
.0.rcgu.o.rcgu.o):/rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/fmt/num.rs:155: first defined here
/usr/bin/ld: objs/ngx_rust_examples/ngx-release/examples/libcurl.a(curl-de3e6fe882b906f0.core-f5a882967048065e.core.ecb3f420ec5f4bcf-cgu.0.rcgu.o.
rcgu.o): in function `core::fmt::num::<impl core::fmt::UpperHex for i64>::fmt':
/rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/fmt/num.rs:155: multiple definition of `core::fmt::num::<impl core::fmt::UpperHex
for usize>::fmt'; objs/ngx_rust_examples/ngx-release/examples/libawssig.a(awssig-22b3aae1e52dce40.core-f5a882967048065e.core.ecb3f420ec5f4bcf-cgu
.0.rcgu.o.rcgu.o):/rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/fmt/num.rs:155: first defined here
/usr/bin/ld: objs/ngx_rust_examples/ngx-release/examples/libcurl.a(curl-de3e6fe882b906f0.core-f5a882967048065e.core.ecb3f420ec5f4bcf-cgu.0.rcgu.o.
rcgu.o): in function `core::fmt::num::<impl core::fmt::LowerHex for i64>::fmt':
/rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/fmt/num.rs:155: multiple definition of `core::fmt::num::<impl core::fmt::LowerHex
for u64>::fmt'; objs/ngx_rust_examples/ngx-release/examples/libawssig.a(awssig-22b3aae1e52dce40.core-f5a882967048065e.core.ecb3f420ec5f4bcf-cgu.0
.rcgu.o.rcgu.o):/rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/fmt/num.rs:155: first defined here
/usr/bin/ld: objs/ngx_rust_examples/ngx-release/examples/libcurl.a(curl-de3e6fe882b906f0.core-f5a882967048065e.core.ecb3f420ec5f4bcf-cgu.0.rcgu.o.
rcgu.o): in function `core::fmt::num::<impl core::fmt::UpperHex for i64>::fmt':
/rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/fmt/num.rs:155: multiple definition of `core::fmt::num::<impl core::fmt::UpperHex
for u64>::fmt'; objs/ngx_rust_examples/ngx-release/examples/libawssig.a(awssig-22b3aae1e52dce40.core-f5a882967048065e.core.ecb3f420ec5f4bcf-cgu.0
.rcgu.o.rcgu.o):/rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/fmt/num.rs:155: first defined here
collect2: error: ld returned 1 exit status
make[1]: *** [objs/Makefile:310: objs/nginx] Error 1
make[1]: Leaving directory '/media/psf/workspace/nginx/nginx'
make: *** [Makefile:10: build] Error 2
(747 of 929): multiple definition of `core::num::from_str_radix_panic_rt'; objs/ngx_rust_examples/ngx-release/examples/libawssig.a(awssig-22b3aae1
e52dce40.core-f5a882967048065e.core.ecb3f420ec5f4bcf-cgu.0.rcgu.o.rcgu.o):/rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/num/mod
.rs:1399: first defined here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing lto = "thin"
from profile.ngx-release solves the issue.
A new file, `examples/auto/rust`, can be used in the module projects to simplify the build and hide most of the platform-specific details. `examples/config` and `examples/config.make` are reimplemented using the library.
f8bff78
to
32ae86e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise looks good.
@@ -0,0 +1,313 @@ | |||
#!/bin/sh | |||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing spaces
diff --git a/examples/auto/rust b/examples/auto/rust
index 2fa79f15..32aaeb0f 100644
--- a/examples/auto/rust
+++ b/examples/auto/rust
@@ -1,13 +1,13 @@
#!/bin/sh
#
# Copyright 2025 Nginx, Inc.
-#
+#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
The whole thing now kind of works on Windows1. Also on NetBSD, OpenBSD and Illumos.
Getting closer to the "Tested OS and platforms" of nginx.
In the course of debugging,
examples/config
accumulated too many subtle details so I split it into a reusableexamples/auto/rust
. The idea is to drop the file into your project, copyconfig.make
and write a minimalconfig
.TODOs:
auto/rust
to allow redistribution.NGX_OBJS
toNGINX_BUILD_DIR
Things to address later:
NGX_ALIGNMENT
redefined via--with-cc-opt
and add a compile-time assertion for insufficient alignment, UseCFLAGS
from the Makefile #118nginx-sys/build/vendored.rs
Footnotes
with a couple of patches: nginx#457 and
sed -i -e 's/^\(#define _WIN32_WINNT\).*/\1 0x0600/' src/os/win32/ngx_win32_config.h
↩