nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
22.76k stars 2.27k forks source link

Support for OpenBSD/adJ #20931

Closed vtamara closed 2 days ago

vtamara commented 7 months ago

Description

Binaries for OpenBSD available

Motivation

Developers and users of OpenBSD need it. For example I need it in order to compile napi-rs, see https://github.com/napi-rs/napi-rs/issues/1183

Suggested Implementation

Adding openbsd as supported platform and compiling to generate a binary.

Alternate Implementations

vtamara commented 7 months ago

Following the instructions of CONTRIBUTING.md, pnpm i fails with:

node_modules/.pnpm/esbuild@0.18.17/node_modules/esbuild: Running postinstall scrnode_modules/.pnpm/esbuild@0.17.6/node_modules/esbuild: Running postinstall scri
node_modules/.pnpm/nx@17.1.2_@swc-node+register@1.6.8_@swc+core@1.3.86/node_modules/nx: Running postinstall script, failed in 612ms
.../node_modules/nx postinstall$ node ./bin/post-install                   
│ /home/vtamara/comp/rust/nx/node_modules/.pnpm/nx@17.1.2_@swc-node+register@…
│     throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
│     ^                                                                         
│ Error: Unsupported OS: openbsd, architecture: x64                
│     at Object.<anonymous> (/home/vtamara/comp/rust/nx/node_modules/.pnpm/nx…
│     at Module._compile (node:internal/modules/cjs/loader:1256:14)
│     at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
│     at Module.load (node:internal/modules/cjs/loader:1119:32)   
│     at Module._load (node:internal/modules/cjs/loader:960:12)
│     at Module.require (node:internal/modules/cjs/loader:1143:19)            
│     at require (node:internal/modules/cjs/helpers:119:18)        
│     at Object.<anonymous> (/home/vtamara/comp/rust/nx/node_modules/.pnpm/nx…
│     at Module._compile (node:internal/modules/cjs/loader:1256:14)
│     at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)                    

Are there instructions to do like a bootstrap to compile the binary withouth requiring the binary?

Cammisuli commented 7 months ago

To build nx, we use nx. So if the platform isn't supported then we can't install the native binary for it.

Adding more supported platforms is something that I want, but we need to have the platform to build on in CI. We currently try to build for FreeBSD (which isn't an officially supported platform on GitHub actions) and that causes issues every time the wind blows. Adding more platforms that aren't compatible increases the maintenance costs for us, and isn't worth it currently.

We do have a planned workaround; by using wasm for platforms that aren't Linux, windows or Mac. But this isn't ready yet. Hopefully it'll be coming soon.

vtamara commented 2 months ago

On OpenBSD/adJ 7.4 I cloned the repository and then run:

cd nx/packages/nx/src/native
cargo

This advances in the compilation but stops with

   Compiling watchexec v3.0.1
   ...
error[E0658]: use of unstable library feature 'local_key_cell_methods'
  --> /home/vtamara/.cargo/registry/src/index.crates.io-6f17d22bba15001f/watchexec-3.0.1/src/id.rs:17:25
   |
17 |         let counter = COUNTER.get();
   |                               ^^^
   |
   = note: see issue #92122 <https://github.com/rust-lang/rust/issues/92122> for more information

error[E0658]: use of unstable library feature 'local_key_cell_methods'
  --> /home/vtamara/.cargo/registry/src/index.crates.io-6f17d22bba15001f/watchexec-3.0.1/src/id.rs:18:11
   |
18 |         COUNTER.set(counter.wrapping_add(1));
   |                 ^^^
   |
   = note: see issue #92122 <https://github.com/rust-lang/rust/issues/92122> for more information

For more information about this error, try `rustc --explain E0658`.
error: could not compile `watchexec` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...

On this platform rustc reports:

% rustc --version
rustc 1.72.1 (d5c2e9c34 2023-09-13) (built from a source tarball)

Checking https://github.com/search?q=repo%3Arust-lang%2Frust%20local_key_cell_methods&type=code seems that this feature was added in rustc 1.73 so I will be updating and testing again.

qd3v commented 1 month ago

That would be amazing to support aarch64-unknown-freebsd rust target too. We have FreeBSD on all AWS Graviton3 instances where LXC is not required (basically LXC is the only reason we forced to use Linux). I'm using packer and AWS *7g instances to build freebsd-aarch64 versions of loki, tempo and all the telemetry stuff. Everything went smoothly until I added grafana in build queue. That is ridiculous, but huge and popular grafana build stuck on nx dependency that can't be satisfied :( I would love to help, but I know nothing about JS and my rust skills are pretty low :(

FrozenPandaz commented 2 days ago

This was fixed with #22870. :tada: