Comments (8)
Got this error when wanting to use onig with wasm32-unknown-unknown
. Then I remembered when I was working with emscripten once, that Rust doesn't really allow you to compile C libraries unless it's with emscripten. Except the emscripten target is not maintained well..
from rust-onig.
Last I knew, building C libraries is only possible with emscripten unfortunately.
Edit: rustwasm/team#291 and rustwasm/team#291 (comment)
from rust-onig.
Iโve never built Onig for WASM. The Artichoke peeps have though. This is their reference: https://github.com/artichoke/artichoke/blob/414b7a2fe387c480d1385efb0f63963153754a3e/artichoke-backend/Cargo.toml#L31
from rust-onig.
I wonder if the default features could be the difference. Disabling that will mean we donโt try to generate an up to date set of bindings and fall back on our built in set. I guess we have one that works for WASM if Artichoke has it working.
from rust-onig.
I guess we have one that works for WASM if Artichoke has it working.
Artichoke does not build with wasm32-unknown-unknown
-- it builds with wasm32-unknown-emscripten
. In general, when building C sources as part of a Rust lib or binary, the wasm32-unknown-unknown
will not work. There is no C standard library in wasm32-unknown-unknown
.
This upstream issue is relevant for one reason why this doesn't work: rustwasm/team#291.
from rust-onig.
The Artichoke peeps have though.
@iwillspeak next time, please feel free to @ me if there's onig-Artichoke questions I can help with ๐
from rust-onig.
On Ubtuntu 18.04, using "wasm-pack", I had got the same fatal error: 'stdlib.h' file not found
problem, mentioned in the original issue description.
I have solved it by
export CPATH=/usr/include
However, now I get the error message
rust-lld: error: duplicate symbol: OnigEncodingASCII
>>> defined in /home/marco/workspace/private/wasm-game-of-life-2/target/wasm32-unknown-unknown/debug/deps/libonig_sys-538ff2b6c9a16eb8.rlib(regexec.o)
>>> defined in /home/marco/workspace/private/wasm-game-of-life-2/target/wasm32-unknown-unknown/debug/deps/libonig_sys-538ff2b6c9a16eb8.rlib(regerror.o)
Is this the kind of error that will vanish when I somehow configure wasm-pack to create a wasm32-unknown-emscripten target output?
Have you seen this error before?
(I have now solved my original problem by using a different regexp crate, but maybe this comment is somehow helpful, so I leave it here).
from rust-onig.
Doing some more digging on this, it seems that the underlying c library, Oniguruma, doesn't build cleanly on either wasm32-unknown-unknown
, or wasm32-unknown-emscripten
. Not sure what we can do better about this from an Onig point of view. If anyone has more experience with these toolchains and wants to open a PR with suggested improvements it would be more than welcome.
EDIT Scratch that. Onig does build on Emscripten if you have the rust target wasm32-unknown-emscripten
installed and use
cargo build --no-default-features --target=wasm32-unknown-emscripten --features=generate
I'm not really sure what we can do about building for -unknown-unknown
though. The build fails there because it can't find c libraries:
running: "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "/home/will/Repositories/rust-onig/target/wasm32-unknown-unknown/debug/build/onig_sys-d79b79668a7ad64f/out" "-I" "oniguruma/src" "-DONIG_DISABLE_DIRECT_THREADING=1" "-DONIG_EXTERN=__attribute__((visibility(\"default\")))" "-o" "/home/will/Repositories/rust-onig/target/wasm32-unknown-unknown/debug/build/onig_sys-d79b79668a7ad64f/out/oniguruma/src/regexec.o" "-c" "oniguruma/src/regexec.c"
cargo:warning=In file included from oniguruma/src/regexec.c:36:
cargo:warning=oniguruma/src/regint.h:109:10: fatal error: 'stdlib.h' file not found
cargo:warning=#include <stdlib.h>
cargo:warning= ^~~~~~~~~~
cargo:warning=1 error generated.
Still open to any PRs if people want to contribute, but closing this issue for now.
from rust-onig.
Related Issues (20)
- Deprecated Pattern Features in `std-pattern`
- ?= +velookahead regex did not return intended result. HOT 1
- Installing on CentOS 7 with llvm-7.0 and rust 1.42 fails with `LLVM ERROR: inconsistency in registered CommandLine option` HOT 3
- new release for bindgen update? HOT 1
- Support `onigmo` Backend HOT 1
- cargo test segfaulting on i386 HOT 9
- Question about regex replace. HOT 2
- onig has a dependency on onig_sys 69.7.0 in crates HOT 9
- Failure with Valid Input HOT 1
- the bindgen used seem to be incompatible with clang-16
- can't build on mac HOT 1
- Bug: `.{0,99}` and `.*` give different results, even without long lines in content HOT 1
- Unexpected `panic`s when `onig` returns an error when searching
- `onig_sys` no longer builds, please make a new release! HOT 1
- unable to build on mac
- Nested alternations don't seem to work
- build failed due to onig C lib
- failed due to undefined reference to onig_new_match_param and onig_free_match_param
- Caret not being treated as literal in rust-onig
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-onig.