Code Monkey home page Code Monkey logo

Comments (8)

MolotovCherry avatar MolotovCherry commented on June 21, 2024 1

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.

MolotovCherry avatar MolotovCherry commented on June 21, 2024 1

Last I knew, building C libraries is only possible with emscripten unfortunately.

Edit: rustwasm/team#291 and rustwasm/team#291 (comment)

from rust-onig.

iwillspeak avatar iwillspeak commented on June 21, 2024

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.

iwillspeak avatar iwillspeak commented on June 21, 2024

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.

lopopolo avatar lopopolo commented on June 21, 2024

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.

lopopolo avatar lopopolo commented on June 21, 2024

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.

shybyte avatar shybyte commented on June 21, 2024

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.

iwillspeak avatar iwillspeak commented on June 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.