Commit graph

312 commits

Author SHA1 Message Date
Andrew Clayton
b5fe3eaf1a auto, wasm-wc: Copy the .so into build/lib/unit/modules/
Normally when the language modules are built, they are built directly
into the build/lib/unit/modules/ directory.

This then allows Unit to find them without being installed. This is
useful for things like the pytests.

This wasn't happening for the wasm-wasi-component language module. So we
now copy it over and give it the right name as part of the make/build
process.

Reported-by: Andrei Zeliankou <zelenkov@nginx.com>
Fixes: 4e6d7e876 ("Wasm-wc: Wire it up to the build system")
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-07-08 15:43:17 +01:00
Andrew Clayton
0e6cc6dcfb auto: Fix some indentation in auto/modules/wasm-wasi-component
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-07-08 15:43:17 +01:00
Alejandro Colomar
d96d583328
Use octal instead of mode macros
They are more readable.

And we had a mix of both styles; there wasn't really a consistent style.

Tested-by: Andrew Clayton <a.clayton@nginx.com>
Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2024-06-18 22:59:45 +02:00
Alejandro Colomar
2e2e5d1e8e
auto: Don't install $runstatedir
This directory should exist already in the system, and if not, it should
(and will) be created at run time, not at install time.

It triggered a warning in Alpine Linux's packaging system:

    ERROR: unit*: Packages must not put anything under /var/run

Fixes: 5a37171f73 ("Added default values for pathnames.")
Fixes: 57fc9201cb ("Socket: Created control socket & pid file directories.")
Closes: <https://github.com/nginx/unit/issues/742>
Reported-by: Andy Postnikov <apostnikov@gmail.com>
Tested-by: Andy Postnikov <apostnikov@gmail.com>
Tested-by: Andrew Clayton <a.clayton@nginx.com>
Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Cc: Liam Crilly <liam@nginx.com>
Cc: Konstantin Pavlov <thresh@nginx.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2024-06-18 22:59:45 +02:00
Arjun
965fc94e49 fuzzing: add fuzzing infrastructure in build system
Signed-off-by: Arjun <pkillarjun@protonmail.com>
Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-06-14 15:11:38 +01:00
Sergey A. Osokin
da43f4434a java: Update third-party components
[ Tweaked subject - Andrew ]
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-05-08 23:06:43 +01:00
Andrew Clayton
5d1ce5c447 auto, perl: Fix building the Perl language module with clang
When we added -fno-strict-overflow to the CFLAGS back in c1e3f02f9
("Compile with -fno-strict-overflow") we inadvertently broke building
the Perl language module with clang, e.g

  $ make
    CC     build/src/perl/nxt_perl_psgi-perl.o
  clang: error: argument unused during compilation: '-fno-strict-overflow' [-Werror,-Wunused-command-line-argument]

This is due to for example on Apline

  $ perl -MExtUtils::Embed -e ccflags
   -D_REENTRANT -D_GNU_SOURCE -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64

Where on clang the -fwrapv causes the -fno-strict-overflow to be
discarded resulting in the above error.

We can get around that by simply appending -Qunused-arguments to the
Perl CFLAGS.

This fixes things for _some_ systems, as there is actually another issue
with building this with clang on Fedora (and probably Red Hat) in that
there the Perl ccflags & ldopts have been heavily modified and uses
flags simply not only not in clang (which we can work around as above)
but also incompatible flags, e.g

  $ make perl
    CC     build/src/perl/nxt_perl_psgi-perl.o
  clang: error: optimization flag '-ffat-lto-objects' is not supported [-Werror,-Wignored-optimization-argument]

There doesn't seem to be an easy workaround like -Qunused-arguments for
this.

While we could work around it in some way, I'm not sure it's worth the
effort right now. On Red Hat & Fedora GCC _is_ the system compiler.

This could be revisited if we find people trying to build this on
Red Hat/Fedora with clang...

For comparison this is the Alpine Perl ccflags & ldops

$ perl -MExtUtils::Embed -e ccflags
 -D_REENTRANT -D_GNU_SOURCE -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 alpine:~$
$ perl -MExtUtils::Embed -e ldopts
-rdynamic -Wl,-rpath,/usr/lib/perl5/core_perl/CORE  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/perl5/core_perl/CORE -lperl -lpthread -ldl -lm -lcrypt -lutil -lc

Fedora

$ perl -MExtUtils::Embed -e ccflags
 -D_REENTRANT -D_GNU_SOURCE -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fwrapv -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
$ perl -MExtUtils::Embed -e ldopts
-Wl,--enable-new-dtags -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1  -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib64/perl5/CORE -lperl -lpthread -lresolv -ldl -lm -lcrypt -lutil -lc

Fixes: c1e3f02f9 ("Compile with -fno-strict-overflow")
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-05-07 17:36:35 +01:00
Andrew Clayton
5b01bd652a auto/wasm: No need to explicitly set -fno-strict-aliasing now
Since commit 0b5223e1c ("Disable strict-aliasing in clang by default")
we explicitly always build with -fno-strict-aliasing so there's no need
to set it independently in auto/modules/wasm

Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-05-07 02:43:24 +01:00
Andrei Zeliankou
e6d8fc6614 njs (lowercase) is more preferred way to mention 2024-04-10 13:30:02 +01:00
Andrew Clayton
a8cfea8b68 Rebuild wasm-wasi-component when any of its dependencies change
Have cargo run if for example src/wasm-wasi-component/src/lib.rs is
changed, or any of the other files that should perhaps trigger a
rebuild.

Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-14 16:09:31 +00:00
Alejandro Colomar
b65e49c5d6 Build with -std=gnu11 (C11 with GNU extensions)
Currently Unit doesn't specify any specific C standard for compiling and
will thus be compiled under whatever the compiler happens to default to.

Current releases of GCC and Clang (13.x & 17.x respectively at the time
of writing) default to gnu17 (C17 + GNU extensions).

Our oldest still-supported system is RHEL/CentOS 7, that comes with GCC
4.8.5 which defaults to gnu90.

Up until now this hasn't really been an issue and we have been able to
use some C99 features that are implemented as GNU extensions in older
compilers, e.g

  -  designated initializers
  -  flexible array members
  -  trailing comma in enum declaration (compiles with -std=c89, warns
     with -std=c89 -pedantic)
  -  snprintf(3)
  -  long long (well we test for it but don't actually use it)
  -  bool / stdbool.h
  -  variadic macros

However there are a couple of C99 features that aren't GNU extensions
that would be handy to be able to use, i.e

 -  The ability to declare variables inside for () loops, e.g

        for (int i = 0; ...; ...)

 -  C99 inline functions (not to be confused with what's available with
    -std=gnu89).

However, if we are going to switch up to C99, then perhaps we should
just leap frog to C11 instead (the Linux Kernel did in fact make the
switch from gnu89 to gnu11 in March '22). C17 is perhaps still a little
new and is really just C11 + errata.

GCC 4.8 as in RHEL 7 has *some* support for C11, so while we can make
full use of C99, we couldn't yet make full use of C11, However RHEL 7 is
EOL on June 30th 2024, after which we will no longer have that
restriction and in the meantime we can restrict ourselves to the
supported set of features (or implement fallbacks where appropriate).

It can only be a benefit that we would be compiling Unit consistently
under the same language standard.

This will also help give the impression that Unit is a modern C code
base.

It is also worth noting the following regarding GCC

 "A version with corrections integrated was prepared in 2017 and published
  in 2018 as ISO/IEC 9899:2018; it  is known as C17 and is supported with
  -std=c17 or -std=iso9899:2017; the corrections are also applied with -
  std=c11, and the only difference between the options is the value of
  STDC_VERSION."

Suggested-by: Andrew Clayton <a.clayton@nginx.com>
Acked-by: Andrew Clayton <a.clayton@nginx.com>
[ Andrew wrote the commit message ]
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Link: <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e8c07082a810fbb9db303a2b66b66b8d7e588b53>
Link: <https://www.ibm.com/blog/announcement/ibm-is-announcing-red-hat-enterprise-linux-7-is-going-end-of-support-on-30-june-2024/>
Link: <https://gcc.gnu.org/onlinedocs/gcc-8.1.0/gcc/Standards.html#C-Language>
Cc: Dan Callahan <d.callahan@f5.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-13 16:29:24 +00:00
Andrei Zeliankou
9993814d14 NJS: loader should be registered using njs_vm_set_module_loader()
This change makes NJS module incompatible with NJS older than 0.8.3.
Therefore, the configuration version check has been adjusted accordingly.

This change was introduced in NJS 0.8.3 here:
<https://hg.nginx.com/njs/rev/ad1a7ad3c715>
2024-03-12 16:56:11 +00:00
Andrew Clayton
a171b39922 Add an EXTRA_CFLAGS make variable
This variable is _appended_ to the main CFLAGS variable and allows
setting extra compiler options at make time. E.g

  $ make EXTRA_CFLAGS="..." ...

Useful for quickly testing various extra warning flags.

Suggested-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-09 01:40:24 +00:00
Andrew Clayton
f55fa70c69 Add a help target to the root Makefile
This adds a help target to the Makefile in the repository root that
shows what variables are available to control the make/build behaviour.
It currently looks like

  $ make help
  Variables to control make/build behaviour:

    make V=1 ...           - Enables verbose output
    make D=1 ...           - Enables debug builds (-O0)
    make E=0 ...           - Disables -Werror

    Variables can be combined.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-09 01:40:24 +00:00
Andrew Clayton
d23812b8f4 Allow to disable -Werror at 'make' time
Having -Werror enabled all the time when developing can be a nuisance,
allow to disable it by passing E=0 to make, e.g

  $ make E=0 ...

This will set -Wno-error overriding the previously set -Werror.

Co-developed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-09 01:40:24 +00:00
Andrew Clayton
15072fbde9 Enable optional 'debuggable' builds
One issue you have when trying to debug Unit under say GDB is that at
the default optimisation level we use of -O (-O1) the compiler will
often optimise things out which means they are not available for
inspection in the debugger.

This patch allows you to pass 'D=1' to make, e.g

  $ make D=1 ...

Which will set -O0 overriding the previously set -O, basically disabling
optimisations, we could use -Og, but the clang(1) man page says this is
best and it seems to not cause any issues when debugging GCC generated
code.

Co-developed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-09 01:40:18 +00:00
Andrew Clayton
b763ba7ecc Pretty print the wasm language module compiler output
This makes use of the infrastructure introduced in a previous commit, to
pretty print the make output when building the wasm language module.

You can still get the old verbose output with

  $ make V=1 ...

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-09 01:36:23 +00:00
Andrew Clayton
133f75fd1b Pretty print the Ruby language module compiler output
This makes use of the infrastructure introduced in a previous commit, to
pretty print the make output when building the Ruby language module.

You can still get the old verbose output with

  $ make V=1 ...

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-09 01:36:23 +00:00
Andrew Clayton
caaa1d288c Pretty print the Python language module compiler output
This makes use of the infrastructure introduced in a previous commit, to
pretty print the make output when building the Python language module.

You can still get the old verbose output with

  $ make V=1 ...

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-09 01:36:23 +00:00
Andrew Clayton
0a0dcf91a5 Pretty print the PHP language module compiler output
This makes use of the infrastructure introduced in a previous commit, to
pretty print the make output when building the PHP language module.

You can still get the old verbose output with

  $ make V=1 ...

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-09 01:36:23 +00:00
Andrew Clayton
574528f7a1 Pretty print the Perl language module compiler output
This makes use of the infrastructure introduced in a previous commit, to
pretty print the make output when building the Perl language module.

You can still get the old verbose output with

  $ make V=1 ...

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-09 01:36:23 +00:00
Andrew Clayton
da335bec08 Pretty print the Java language module compiler output
This makes use of the infrastructure introduced in a previous commit, to
pretty print the make output when building the Java language module.

You can still get the old verbose output with

  $ make V=1 ...

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-09 01:36:23 +00:00
Andrew Clayton
5d831af0b0 Hook up make pretty printing to the Unit core and tests
This makes use of the infrastructure introduced in the previous commit
to pretty print the make output when building the Unit core and the C
test programs.

When building Unit the output now looks like

  VER    build/include/nxt_version.h (NXT_VERSION)
  VER    build/include/nxt_version.h (NXT_VERNUM)
  CC     build/src/nxt_lib.o
  CC     build/src/nxt_gmtime.o
  ...
  CC     build/src/nxt_cgroup.o
  AR     build/lib/libnxt.a
  CC     build/src/nxt_main.o
  LD     build/sbin/unitd
  SED    build/share/man/man8/unitd.8

I'm sure you'll agree that looks much nicer!

You can still get the old verbose output with

  $ make V=1 ...

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-09 01:36:23 +00:00
Andrew Clayton
280a978d9a Add initial infrastructure for pretty printing make output
The idea is rather than printing out the full compiler/linker etc
command for each recipe e.g

  cc -c -pipe -fPIC -fvisibility=hidden -O0 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wno-strict-aliasing -Wmissing-prototypes  -g   -I src -I build/include   \
                        \
                       \
  -o build/src/nxt_cgroup.o \
  -MMD -MF build/src/nxt_cgroup.dep -MT build/src/nxt_cgroup.o \
  src/nxt_cgroup.c

Print a clearer abbreviated message e.g the above becomes

  CC     build/src/nxt_cgroup.o

This vastly reduces the noise when compiling and most of the time you
don't need to see the full command being executed.

This also means that warnings etc show up much more clearly.

You can still get the old verbose output by passing V=1 to make e.g

  $ make V=1 ...

NOTE: With recent versions of make(1) you can get this same, verbose,
behaviour by using the --debug=print option.

This introduces the following message types

  CC	  Compiling a source file to an object file.
  AR	  Producing a static library, .a archive file.
  LD	  Producing a dynamic library, .so DSO, or executable.
  VER	  Writing version information.
  SED	  Running sed(1).

All in all this improves the developer experience.

Subsequent commits will make use of this in the core and modules.

NOTE: This requires GNU make for which we check. On OpenIndiana/illumos
we have to use gmake(1) (GNU make) anyway as the illumos make doesn't
work with our Makefile as it is. Also macOS seems to generally install
GNU make.

We could make it work (probably) on other variants of make, but the
complexity starts increasing exponentially.

In fact we still print the abbreviated messages in the verbose output so
you can still do

  $ make | grep ^"  [A-Z]"

on other makes to effectively get the same output.

Co-developed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-09 01:36:23 +00:00
Andrew Clayton
c1e3f02f99 Compile with -fno-strict-overflow
This causes signed integer & pointer overflow to have a defined
behaviour of wrapping according to two's compliment. I.e INT_MAX will
wrap to INT_MIN and vice versa.

This is mainly to cover existing cases, not an invitation to add more.

Cc: Dan Callahan <d.callahan@f5.com>
Suggested-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-09 00:42:27 +00:00
Andrew Clayton
0b5223e1cd Disable strict-aliasing in clang by default
Aliasing is essentially when you access the same memory via different
types.

If the compiler knows this doesn't happen it can make some
optimisations.

There is however code in Unit, for example in the wasm language module
and the websocket code that may fall foul of strict-aliasing rules.

(For the wasm module I explicitly disable it there)

In auto/cc/test for GCC we have

  NXT_CFLAGS="$NXT_CFLAGS -O"
  ...
  # -O2 enables -fstrict-aliasing and -fstrict-overflow.
  #NXT_CFLAGS="$NXT_CFLAGS -O2"
  #NXT_CFLAGS="$NXT_CFLAGS -Wno-strict-aliasing"

So with GCC by default we effectively compile with -fno-strict-aliasing.

For clang we have this

  NXT_CFLAGS="$NXT_CFLAGS -O"
  ...
  #NXT_CFLAGS="$NXT_CFLAGS -O2"
  ...
  NXT_CFLAGS="$NXT_CFLAGS -fstrict-aliasing"

(In _clang_, -fstrict-aliasing is always enabled by default)

So in clang we always build with -fstrict-aliasing. I don't think this
is the best idea, building with something as fundamental as this
disabled in one compiler and enabled in another.

This patch adjusts the Clang side of things to match that of GCC. I.e
compile with -fno-strict-aliasing. It also explicitly sets
-fno-strict-aliasing for GCC, which is what we were getting anyway but
lets be explicit about it.

Cc: Dan Callahan <d.callahan@f5.com>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-09 00:42:27 +00:00
Andrew Clayton
1dcb538331 Expand the comment about -Wstrict-overflow on GCC
Expand on the comment on why we don't enable -Wstrict-overflow=5 on GCC.

Link: <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96658>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-09 00:42:27 +00:00
Andrew Clayton
806e209df5 Remove -W from compiler flags
This is what -Wextra used to be called, but any version of GCC or Clang
in at least the last decade has -Wextra.

Cc: Dan Callahan <d.callahan@f5.com>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-09 00:42:27 +00:00
Andrew Clayton
9cd11133f9 Remove support for Sun's Sun Studio/SunPro C compiler
We really only support building Unit with GCC and Clang.

Cc: Dan Callahan <d.callahan@f5.com>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-09 00:42:27 +00:00
Andrew Clayton
e79e463556 Remove support for IBM's XL C compiler
We really only support building Unit with GCC and Clang.

Cc: Dan Callahan <d.callahan@f5.com>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-09 00:42:27 +00:00
Andrew Clayton
0c2d7786b1 Remove support for Intel's icc compiler
We only really support building Unit with GCC and Clang.

Cc: Dan Callahan <d.callahan@f5.com>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-09 00:42:27 +00:00
Andrew Clayton
5511593dac Remove support for Microsoft's Visual C++ compiler
We don't run on Windows and only really support compiling Unit with GCC
and Clang.

Cc: Dan Callahan <d.callahan@f5.com>
Co-developed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-09 00:42:27 +00:00
Andrew Clayton
4eb008bb17 Remove unused nxt_vector_t API
This is unused, yet a community member just spent time finding and
fixing a bug in it only to be told it's unused.

Just get rid of the thing.

Link: <https://github.com/nginx/unit/pull/963>
Reviewed-by: Zhidao Hong <z.hong@f5.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-03-05 23:05:52 +00:00
Konstantin Pavlov
23e807dea3 Wasm-wc: use more common uname switch to get operating system name
-o is not available on macOS 12.7 at least, and it's what homebrew seems
to support still.

Also, the proposed switch seems to be used already in the codebase.
2024-02-27 16:44:42 -08:00
Sergey A. Osokin
2f3c7c2c07 Update third-party java components to their recent versions
Acked-by: Timo Stark <t.stark@nginx.com>
[ Remove trailing '.' from subject line - Andrew ]
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-02-22 03:56:20 +00:00
Andrew Clayton
d54af163c4 Wasm-wc: Use the cargo build output as the make target dependency
cargo build creates the language module under
src/wasm-wasi-component/target/release/libwasm_wasi_component.so and not
build/lib/unit/modules/wasm_wasi_component.unit.so which is what we were
using as a target dependency in the Makefile which doesn't exist so this
resulted in the following

  $ make wasm-wasi-component-install
  cargo build --release --manifest-path src/wasm-wasi-component/Cargo.toml
      Finished release [optimized] target(s) in 0.17s
  install -d /opt/unit/modules
  install -p src/wasm-wasi-component/target/release/libwasm_wasi_component.so \
          /opt/unit/modules/wasm_wasi_component.unit.so

I.e it wanted to rebuild the module, after this patch we get the more
correct

  $ make wasm-wasi-component-install
  install -d /opt/unit/modules
  install -p src/wasm-wasi-component/target/release/libwasm_wasi_component.so \
          /opt/unit/modules/wasm_wasi_component.unit.so

This is all a little ugly because we're fighting against cargo wanting
to do its own thing and this wasm-wasi-component language module build
process is likely going to get some re-working anyway, so this will do
for now.

Reported-by: Konstantin Pavlov <thresh@nginx.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-02-22 03:17:08 +00:00
Andrew Clayton
7b13c30604 Wasm-wc: Add nxt_unit.o as a dependency in the auto script
Rather than calling make itself to build nxt_unit.o make nxt_unit.o a
dependency of the main module build target.

Reported-by: Konstantin Pavlov <thresh@nginx.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-02-22 03:17:08 +00:00
Andrew Clayton
4e6d7e8768 Wasm-wc: Wire it up to the build system
Et voila...

  $ ./configure wasm-wasi-component
  configuring wasm-wasi-component module
  Looking for rust compiler ... found.
  Looking for cargo ... found.
   + wasm-wasi-component module: wasm_wasi_component.unit.so
  $ make install
  test -d /opt/unit/sbin          || install -d /opt/unit/sbin
  install -p build/sbin/unitd /opt/unit/sbin/
  test -d /opt/unit/state                 || install -d /opt/unit/state
  test -d /opt/unit               || install -d /opt/unit
  test -d /opt/unit               || install -d /opt/unit
  test -d /opt/unit/share/man/man8                || install -d /opt/unit/sh
man/man8
  install -p -m644 build/share/man/man8/unitd.8           /opt/unit/share/ma
n8/
  make build/src/nxt_unit.o
  make[1]: Entering directory '/home/andrew/src/unit'
  make[1]: 'build/src/nxt_unit.o' is up to date.
  make[1]: Leaving directory '/home/andrew/src/unit'
  cargo build --release --manifest-path src/wasm-wasi-component/Cargo.toml
      Finished release [optimized] target(s) in 0.55s
  install -d /opt/unit/modules
  install -p src/wasm-wasi-component/target/release/libwasm_wasi_component.so \
          /opt/unit/modules/wasm_wasi_component.unit.so

Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-02-21 16:20:32 +00:00
Andrew Clayton
da44dc00dc Fix alignment of wasm options text in auto/help
The indentation uses spaces and not TABs.

Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-02-21 16:20:32 +00:00
Andrei Zeliankou
f71ead5fa5 Updated copyright notice. 2024-02-20 16:08:36 +00:00
Andrew Clayton
0c98353091 Node.js: Build/install fix
A user on GitHub reported an issue when trying to build/install the
nodejs language module.

Doing a

  $ ./configure nodejs --node=/usr/bin/node --npm=/usr/bin/npm --node-gyp=/usr/bin/node-gyp
  $ make install

was throwing the following error

  mv build/src//usr/bin/node/unit-http-g/unit-http-1.31.1.tgz build//usr/bin/node-unit-http-g.tar.gz
  mv: cannot move 'build/src//usr/bin/node/unit-http-g/unit-http-1.31.1.tgz' to 'build//usr/bin/node-unit-http-g.tar.gz': No such file or directory
  make: *** [build/Makefile:2061: build//usr/bin/node-unit-http-g.tar.gz] Error 1

The fact that we're using the path given by --node= to then use as
directory locations seems erroneous.

But rather than risk breaking existing expectations the simple fix is to
just use build/src in the destination path above to match that of the
source.

These paths were added in some previous commits, and the missing 'src/'
component looks like an oversight.

After this commit both the following work

  $ ./configure nodejs --node-gyp=/usr/lib/node_modules/bin/node-gyp-bin/node-gyp --local=/opt/unit/node
  $ ./configure nodejs --node=/usr/bin/node --node-gyp=/usr/lib/node_modules/npm/bin/node-gyp-bin/node-gyp --local=/opt/unit/node

Reported-by: ruspaul013 <https://github.com/ruspaul013>
Tested-by: ruspaul013 <https://github.com/ruspaul013>
Fixes: 0ee8de554 ("Fixed Makefile target for NodeJS.")
Fixes: c84948386 ("Node.js: fixing module global installation.")
Reviewed-by: Timo Stark <t.stark@nginx.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-02-19 16:47:27 +00:00
Andrei Zeliankou
a1e00b4e28 White space formatting fixes
Closes: <https://github.com/nginx/unit/pull/1062>
2024-01-16 15:37:07 +00:00
Sergey A. Osokin
a922f9a6f0 Update third-party components for the Java module. 2023-11-29 10:28:44 -05:00
Sergey A. Osokin
5265b7e058 Update third-party components for the Java module. 2023-10-17 13:43:51 -04:00
Sergey A. Osokin
d1a9069852 Update third-party components for the Java module. 2023-10-10 11:55:44 -04:00
Sergey A. Osokin
c905d0d393 Update third-party components for the Java module. 2023-10-06 12:22:03 -04:00
Konstantin Pavlov
ebcc92069d Added unit pkg-config file. 2023-08-01 10:16:17 -07:00
Andrew Clayton
2b4a7eedd0 Wasm: Wire the Wasm language module up to the build system.
This allows to configure the Wasm module, e.g

  ./configure wasm --include-path=/path/to/wasmtime-v11.0.0-x86_64-linux-c-api/include --lib-path=/path/to/wasmtime-v11.0.0-x86_64-linux-c-api/lib --rpath

--rpath as above says to set the rpath to the value of --lib-path. You
can alternatively specify a directory to use as the rpath. Or simply
omit the option to not have an rpath set.

This is mostly useful for during development where you may not have the
Wasmtime stuff installed to system directories or you want to test with
newer/different versions.

See ./configure wasm --help for a full list of options.

Reviewed-by: Alejandro Colomar <alx@nginx.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2023-08-17 13:09:42 +01:00
Zhidao HONG
a28bef097c HTTP: controlling response headers support. 2023-08-09 14:37:16 +08:00
Konstantin Pavlov
497f08d15f NJS: explicitely require 0.8.0 or later versions in configure. 2023-07-11 13:02:43 -07:00