Csound Csound-dev Csound-tekno Search About

[Csnd-dev] Building WASM plugin opcodes

Date2024-10-15 15:15
FromRichard Knight
Subject[Csnd-dev] Building WASM plugin opcodes
Hi,

I'd like to compile some plugin opcodes to use in the browser. As far as 
I can follow this is possible with the repository example in wasm/src 
but would like some advice/help with setting up the correct build 
environment.

I have no experience of any wasm toolchain but had a look at 
wasm/README.md, this says run 'yarn link', but this fails with 'link not 
found' or similar. I then used nix against wasm/src/csound.nix which 
failed apparently when compiling LLVM, with an error that uintptr_t was 
undefined, used in the function CleanupOnSignal. I then had a look at 
wasm/scripts/compile.sh, which failed with a nix syntax error when I ran 
it.
I'm using the latest Debian linux with latest packages etc.

I am a bit confused about exactly what build tools need to be used and 
in which order etc. Eg there is also the package.json file, does this 
imply node is used in some step of the process too?

Thanks
Richard

Date2024-10-15 15:45
FromHlöðver Sigurðsson
SubjectRe: [Csnd-dev] Building WASM plugin opcodes
There's a lot to unpack there. It's unnecessary complicated to do this atm. I would make a new nix file from one of the two plugin examples (one in c and the other in c++) and import it and build it. I recommend a chatGPT handy to help unpack the very undocumented parts there :)

As Steven Yi mentioned in another thread, we want to continue simplify wasm builds and remove nix where nix isn't needed and incorporate more Cmake (which was perhaps done with emscripten PR recently?)

"yarn link" will create a symlink to node_modules to develop changes quickly, it's more for developing the javascript wrapper than it is for building c/c++ plugin code.

On Tue, 15 Oct 2024 at 17:16, Richard Knight <richard@1bpm.net> wrote:
Hi,

I'd like to compile some plugin opcodes to use in the browser. As far as
I can follow this is possible with the repository example in wasm/src
but would like some advice/help with setting up the correct build
environment.

I have no experience of any wasm toolchain but had a look at
wasm/README.md, this says run 'yarn link', but this fails with 'link not
found' or similar. I then used nix against wasm/src/csound.nix which
failed apparently when compiling LLVM, with an error that uintptr_t was
undefined, used in the function CleanupOnSignal. I then had a look at
wasm/scripts/compile.sh, which failed with a nix syntax error when I ran
it.
I'm using the latest Debian linux with latest packages etc.

I am a bit confused about exactly what build tools need to be used and
in which order etc. Eg there is also the package.json file, does this
imply node is used in some step of the process too?

Thanks
Richard

Date2024-10-15 16:37
FromRichard Knight
SubjectRe: [Csnd-dev] Building WASM plugin opcodes

OK thanks! I'll give it another go this evening and see what chatGPT knows..

I am also a bit unclear on how compiled plugin opcodes will work in the context of wasm - if I get that far. Eg if I have my wasm binary compiled from my plugin opcode, does the build process result in a single binary (ie linked csound and opcode) or the plugin binary in addition to the existing csound wasm binary.. and if the latter are there any particular steps that need to be taken to load the opcode binary?

 

On 2024-10-15 15:45, Hlöðver Sigurðsson wrote:

There's a lot to unpack there. It's unnecessary complicated to do this atm. I would make a new nix file from one of the two plugin examples (one in c and the other in c++) and import it and build it. I recommend a chatGPT handy to help unpack the very undocumented parts there :)

As Steven Yi mentioned in another thread, we want to continue simplify wasm builds and remove nix where nix isn't needed and incorporate more Cmake (which was perhaps done with emscripten PR recently?)

"yarn link" will create a symlink to node_modules to develop changes quickly, it's more for developing the javascript wrapper than it is for building c/c++ plugin code.

On Tue, 15 Oct 2024 at 17:16, Richard Knight <richard@1bpm.net> wrote:
Hi,

I'd like to compile some plugin opcodes to use in the browser. As far as
I can follow this is possible with the repository example in wasm/src
but would like some advice/help with setting up the correct build
environment.

I have no experience of any wasm toolchain but had a look at
wasm/README.md, this says run 'yarn link', but this fails with 'link not
found' or similar. I then used nix against wasm/src/csound.nix which
failed apparently when compiling LLVM, with an error that uintptr_t was
undefined, used in the function CleanupOnSignal. I then had a look at
wasm/scripts/compile.sh, which failed with a nix syntax error when I ran
it.
I'm using the latest Debian linux with latest packages etc.

I am a bit confused about exactly what build tools need to be used and
in which order etc. Eg there is also the package.json file, does this
imply node is used in some step of the process too?

Thanks
Richard

Date2024-10-15 16:59
FromMichael Gogins
SubjectRe: [Csnd-dev] Building WASM plugin opcodes
I'd like to know the answer to that myself!

-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Tue, Oct 15, 2024 at 5:38 PM Richard Knight <richard@1bpm.net> wrote:

OK thanks! I'll give it another go this evening and see what chatGPT knows..

I am also a bit unclear on how compiled plugin opcodes will work in the context of wasm - if I get that far. Eg if I have my wasm binary compiled from my plugin opcode, does the build process result in a single binary (ie linked csound and opcode) or the plugin binary in addition to the existing csound wasm binary.. and if the latter are there any particular steps that need to be taken to load the opcode binary?

 

On 2024-10-15 15:45, Hlöðver Sigurðsson wrote:

There's a lot to unpack there. It's unnecessary complicated to do this atm. I would make a new nix file from one of the two plugin examples (one in c and the other in c++) and import it and build it. I recommend a chatGPT handy to help unpack the very undocumented parts there :)

As Steven Yi mentioned in another thread, we want to continue simplify wasm builds and remove nix where nix isn't needed and incorporate more Cmake (which was perhaps done with emscripten PR recently?)

"yarn link" will create a symlink to node_modules to develop changes quickly, it's more for developing the javascript wrapper than it is for building c/c++ plugin code.

On Tue, 15 Oct 2024 at 17:16, Richard Knight <richard@1bpm.net> wrote:
Hi,

I'd like to compile some plugin opcodes to use in the browser. As far as
I can follow this is possible with the repository example in wasm/src
but would like some advice/help with setting up the correct build
environment.

I have no experience of any wasm toolchain but had a look at
wasm/README.md, this says run 'yarn link', but this fails with 'link not
found' or similar. I then used nix against wasm/src/csound.nix which
failed apparently when compiling LLVM, with an error that uintptr_t was
undefined, used in the function CleanupOnSignal. I then had a look at
wasm/scripts/compile.sh, which failed with a nix syntax error when I ran
it.
I'm using the latest Debian linux with latest packages etc.

I am a bit confused about exactly what build tools need to be used and
in which order etc. Eg there is also the package.json file, does this
imply node is used in some step of the process too?

Thanks
Richard