Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't compile jsdec on MacOS #32

Closed
palmerj opened this issue Dec 30, 2022 · 18 comments
Closed

Can't compile jsdec on MacOS #32

palmerj opened this issue Dec 30, 2022 · 18 comments

Comments

@palmerj
Copy link

palmerj commented Dec 30, 2022

❯ rz-pm --debug install jsdec
2022/12/30 23:15:11 Updating rz-pm-db repository...
Building jsdec...
Directory already configured.

Just run your build command (e.g. ninja) and Meson will regenerate as necessary.
If ninja fails, run "ninja reconfigure" or "meson --reconfigure"
to force Meson to regenerate.

If build failures persist, run "meson setup --wipe" to rebuild from scratch
using the same options as passed when configuring the build.
To change option values, run "meson configure" instead.
ninja: Entering directory `build'
[1/2] Compiling C object libcore_pdd.dylib.p/core_pdd.c.o
FAILED: libcore_pdd.dylib.p/core_pdd.c.o
ccache cc -Ilibcore_pdd.dylib.p -I. -I.. -I../duktape -I/usr/local/Cellar/rizin/0.4.1/include/librz -I/usr/local/Cellar/rizin/0.4.1/include/librz/sdb -fcolor-diagnostics -Wall -Winvalid-pch -g '-DJSDEC_HOME="/usr/local/lib/rizin/plugins/jsdec"' -DUSE_JSC -MD -MQ libcore_pdd.dylib.p/core_pdd.c.o -MF libcore_pdd.dylib.p/core_pdd.c.o.d -o libcore_pdd.dylib.p/core_pdd.c.o -c ../core_pdd.c
In file included from ../core_pdd.c:8:
In file included from /usr/local/Cellar/rizin/0.4.1/include/librz/rz_cmd.h:5:
/usr/local/Cellar/rizin/0.4.1/include/librz/rz_util.h:22:10: fatal error: 'openssl/bn.h' file not found
#include <openssl/bn.h>
         ^~~~~~~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.
exit status 1

I have openssl@3 installed via brew and have set the env variables as brew won't link:

export PATH="/usr/local/opt/openssl@3/bin:$PATH
export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@3/include"
❯ brew link --force openssl
Warning: Refusing to link macOS provided/shadowed software: openssl@3
If you need to have openssl@3 first in your PATH, run:
  echo 'export PATH="/usr/local/opt/openssl@3/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl@3 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@3/include"

For pkg-config to find openssl@3 you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig"
@wargio
Copy link
Member

wargio commented Dec 31, 2022

looks like you have a broken installation of rizin, can you try to uninstall and reinstall it? and then try to install jsdec?

@palmerj
Copy link
Author

palmerj commented Dec 31, 2022

Thanks for the reply. How can you tell my install is broken? I just did brew install rizin?

@palmerj
Copy link
Author

palmerj commented Dec 31, 2022

I tired brew reinstall rizin and still the same result. I have radare2 installed as well. Could that be an issue?

@wargio
Copy link
Member

wargio commented Jan 1, 2023

no, i think there are some changes on openssl side which broke the include, but that is weird that you didn't have this issue before

@ret2libc
Copy link
Member

ret2libc commented Jan 2, 2023

@wargio I don't see openssl requested in the meson.build file of jsdec plugin. That could be the reason. You should dependency('openssl') and then use it in the depends of the right targets. Could that be the problem?

@ret2libc
Copy link
Member

ret2libc commented Jan 2, 2023

Something changed indeed, as the rz-pm tests don't pass anymore on my local machine either.

@ret2libc
Copy link
Member

ret2libc commented Jan 2, 2023

Something changed indeed, as the rz-pm tests don't pass anymore on my local machine either.

However it apparently depends on the environment, because https://github.com/rizinorg/rz-pm/actions/runs/3821781197/jobs/6501271914 works.

@wargio I don't see openssl requested in the meson.build file of jsdec plugin. That could be the reason. You should dependency('openssl') and then use it in the depends of the right targets. Could that be the problem?

Sorry, I just realize the OpenSSL inclusion is in Rizin itself. I will check.

@ret2libc
Copy link
Member

ret2libc commented Jan 2, 2023

@palmerj please follow these steps to fix it:

rm -rf /Users/<youruser>/Library/Application Support/rz-pm/site/artifacts/jsdec
export PATH="/usr/local/opt/openssl@3/bin:$PATH
export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@3/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig"
rz-pm --debug install jsdec

the PKG_CONFIG_PATH var is important as that's what we use to discover dependnecies.

I created the following to improve the situation, and I'm closing this.

Please re-open if the above does not work. Thanks for your report!

@ret2libc ret2libc closed this as completed Jan 2, 2023
@palmerj
Copy link
Author

palmerj commented Jan 4, 2023

Ok thank you. I've just installed rizin again via homebrew. It seems to have installed rz-pm which is different to this repos version.

rz-pm -v
rz-pm 0.4.1

It also doesn't have the --debug CLI option.

However with this version I get a different error

❯ rm -rf /Users/jpalmer/Library/Application Support/rz-pm/site/artifacts/jsdec
export PATH="/usr/local/opt/openssl@3/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@3/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig"
rz-pm install jsdec
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 5 (delta 3), reused 4 (delta 3), pack-reused 0
Unpacking objects: 100% (5/5), 862 bytes | 172.00 KiB/s, done.
From https://github.com/rizinorg/jsdec
   275e5b8..497a4dd  master     -> origin/master
Updating 275e5b8..497a4dd
Fast-forward
 .github/workflows/continuous-tests.yml |  8 ++++----
 .gitignore                             |  2 ++
 libdec/arch/arm.js                     | 20 ++++++++++----------
 libdec/arch/x86.js                     | 20 ++++++++++----------
 libdec/rzutil.js                       | 28 +++++-----------------------
 5 files changed, 31 insertions(+), 47 deletions(-)
error: pathspec 'rz-0.4.1' did not match any file(s) known to git
Already up to date.
Install Done For jsdec
gmake: Entering directory '/Users/jpalmer/.local/share/rizin/rz-pm/git/jsdec/p'
Package openssl was not found in the pkg-config search path.
Perhaps you should add the directory containing `openssl.pc'
to the PKG_CONFIG_PATH environment variable
Package 'openssl', required by 'rz_util', not found
[CC] duktape/duktape.o
Package openssl was not found in the pkg-config search path.
Perhaps you should add the directory containing `openssl.pc'
to the PKG_CONFIG_PATH environment variable
Package 'openssl', required by 'rz_util', not found
[CC] duktape/duk_console.o
duktape/duk_console.c:13:10: fatal error: 'rz_cons.h' file not found
#include <rz_cons.h>
         ^~~~~~~~~~~
1 error generated.
gmake: *** [Makefile:30: duktape/duk_console.o] Error 1
gmake: Leaving directory '/Users/jpalmer/.local/share/rizin/rz-pm/git/jsdec/p'

@wargio
Copy link
Member

wargio commented Jan 4, 2023

is that rz-pm a script?
Looks like you are using the script rz-pm which we deprecated in the latest version. this is for the golang version.
Replace your script with one of these bins: https://github.com/rizinorg/rz-pm/releases/tag/v0.1.8

@palmerj
Copy link
Author

palmerj commented Jan 4, 2023

I also tried with the go version:

~/Downloads/rz-pm --debug install jsdec
2023/01/04 10:21:02 Updating rz-pm-db repository...
Building jsdec...
Directory already configured.

Just run your build command (e.g. ninja) and Meson will regenerate as necessary.
If ninja fails, run "ninja reconfigure" or "meson --reconfigure"
to force Meson to regenerate.

If build failures persist, run "meson setup --wipe" to rebuild from scratch
using the same options as passed when configuring the build.
To change option values, run "meson configure" instead.
ninja: Entering directory `build'
[1/2] Compiling C object libcore_pdd.dylib.p/core_pdd.c.o
FAILED: libcore_pdd.dylib.p/core_pdd.c.o
ccache cc -Ilibcore_pdd.dylib.p -I. -I.. -I../duktape -I/usr/local/Cellar/rizin/0.4.1/include/librz -I/usr/local/Cellar/rizin/0.4.1/include/librz/sdb -fcolor-diagnostics -Wall -Winvalid-pch -g '-DJSDEC_HOME="/usr/local/lib/rizin/plugins/jsdec"' -DUSE_JSC -MD -MQ libcore_pdd.dylib.p/core_pdd.c.o -MF libcore_pdd.dylib.p/core_pdd.c.o.d -o libcore_pdd.dylib.p/core_pdd.c.o -c ../core_pdd.c
In file included from ../core_pdd.c:8:
In file included from /usr/local/Cellar/rizin/0.4.1/include/librz/rz_cmd.h:5:
/usr/local/Cellar/rizin/0.4.1/include/librz/rz_util.h:22:10: fatal error: 'openssl/bn.h' file not found
#include <openssl/bn.h>
         ^~~~~~~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.
exit status 1

Openssl and the <openssl/bn.h> header is installed:

brew list openssl
/usr/local/Cellar/openssl@3/3.0.7/.bottle/etc/ (7 files)
/usr/local/Cellar/openssl@3/3.0.7/bin/c_rehash
/usr/local/Cellar/openssl@3/3.0.7/bin/openssl
/usr/local/Cellar/openssl@3/3.0.7/include/openssl/ (135 files)
/usr/local/Cellar/openssl@3/3.0.7/lib/libcrypto.3.dylib
/usr/local/Cellar/openssl@3/3.0.7/lib/libssl.3.dylib
/usr/local/Cellar/openssl@3/3.0.7/lib/engines-3/ (3 files)
/usr/local/Cellar/openssl@3/3.0.7/lib/ossl-modules/legacy.dylib
/usr/local/Cellar/openssl@3/3.0.7/lib/pkgconfig/ (3 files)
/usr/local/Cellar/openssl@3/3.0.7/lib/ (4 other files)
/usr/local/Cellar/openssl@3/3.0.7/share/doc/ (788 files)
/usr/local/Cellar/openssl@3/3.0.7/share/man/ (5502 files)

@ret2libc
Copy link
Member

ret2libc commented Jan 4, 2023

@palmerj did you do the following?

rm -rf /Users/<youruser>/Library/Application Support/rz-pm/site/artifacts/jsdec
export PATH="/usr/local/opt/openssl@3/bin:$PATH
export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@3/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig"
rz-pm --debug install jsdec

@palmerj
Copy link
Author

palmerj commented Jan 4, 2023

Yes. Ran exactly this:

rm -rf /Users/jpalmer/Library/Application Support/rz-pm/site/artifacts/jsdec
export PATH="/usr/local/opt/openssl@3/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@3/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig"
~/Downloads/rz-pm --debug install jsdec

@ret2libc
Copy link
Member

ret2libc commented Jan 4, 2023

Sorry, get the right values for those variables by running brew info openssl. It should give the right values for your system.

@palmerj
Copy link
Author

palmerj commented Jan 4, 2023

Ok so brew info provided this:

If you need to have openssl@3 first in your PATH, run:
  echo 'export PATH="/usr/local/opt/openssl@3/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl@3 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@3/include"

For pkg-config to find openssl@3 you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig"

So I needed to adjust PKG_CONFIG_PATH. But that still didn't work :-(

❯ rm -rf /Users/jpalmer/Library/Application Support/rz-pm/site/artifacts/jsdec
export PATH="/usr/local/opt/openssl@3/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@3/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig"
~/Downloads/rz-pm --debug install jsdec
2023/01/04 13:21:35 Updating rz-pm-db repository...
Building jsdec...
Directory already configured.

Just run your build command (e.g. ninja) and Meson will regenerate as necessary.
If ninja fails, run "ninja reconfigure" or "meson --reconfigure"
to force Meson to regenerate.

If build failures persist, run "meson setup --wipe" to rebuild from scratch
using the same options as passed when configuring the build.
To change option values, run "meson configure" instead.
ninja: Entering directory `build'
[1/2] Compiling C object libcore_pdd.dylib.p/core_pdd.c.o
FAILED: libcore_pdd.dylib.p/core_pdd.c.o
ccache cc -Ilibcore_pdd.dylib.p -I. -I.. -I../duktape -I/usr/local/Cellar/rizin/0.4.1/include/librz -I/usr/local/Cellar/rizin/0.4.1/include/librz/sdb -fcolor-diagnostics -Wall -Winvalid-pch -g '-DJSDEC_HOME="/usr/local/lib/rizin/plugins/jsdec"' -DUSE_JSC -MD -MQ libcore_pdd.dylib.p/core_pdd.c.o -MF libcore_pdd.dylib.p/core_pdd.c.o.d -o libcore_pdd.dylib.p/core_pdd.c.o -c ../core_pdd.c
In file included from ../core_pdd.c:8:
In file included from /usr/local/Cellar/rizin/0.4.1/include/librz/rz_cmd.h:5:
/usr/local/Cellar/rizin/0.4.1/include/librz/rz_util.h:22:10: fatal error: 'openssl/bn.h' file not found
#include <openssl/bn.h>
         ^~~~~~~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.
exit status 1

@ret2libc
Copy link
Member

ret2libc commented Jan 4, 2023

The message "Just run your build command (e.g. ninja) and Meson will regenerate as necessary.
If ninja fails, run "ninja reconfigure" or "meson --reconfigure"
to force Meson to regenerate." means that actually the old build directory is still there.

Run find ~ -path "*/rz-pm/site/artifacts" 2>/dev/null to find the right path to delete.

The tool is still in early dev, thus the pain :) Hopefully I'll make it better soon!

@ret2libc ret2libc reopened this Jan 4, 2023
@palmerj
Copy link
Author

palmerj commented Jan 4, 2023

AH that did it! The path was ok ("/Users/jpalmer/Library/Application Support/rz-pm/site/artifacts/"), but it's needed to be in quotes for the rm command due to the space.

❯ rm -rf "/Users/jpalmer/Library/Application Support/rz-pm/site/artifacts/"
❯ export PATH="/usr/local/opt/openssl@3/bin:$PATH"
❯ export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
❯ export CPPFLAGS="-I/usr/local/opt/openssl@3/include"
❯ export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig"
❯ ~/Downloads/rz-pm --debug install jsdec
2023/01/04 13:41:08 Updating rz-pm-db repository...
Downloading jsdec source archive...
Verifying downloaded archive...
Extracting jsdec code...
Source code for jsdec downloaded and extracted.
Building jsdec...
The Meson build system
Version: 0.58.0
Source dir: /Users/jpalmer/Library/Application Support/rz-pm/site/artifacts/jsdec/0.4.0/jsdec-0.4.0/p
Build dir: /Users/jpalmer/Library/Application Support/rz-pm/site/artifacts/jsdec/0.4.0/jsdec-0.4.0/p/build
Build type: native build
Project name: jsdec
Project version: undefined
C compiler for the host machine: ccache cc (clang 14.0.0 "Apple clang version 14.0.0 (clang-1400.0.29.102)")
C linker for the host machine: cc ld64 819.6
Host machine cpu family: x86_64
Host machine cpu: x86_64
Program python3 found: YES (/usr/local/opt/[email protected]/bin/python3.9)
Found pkg-config: /usr/local/bin/pkg-config (0.29.2)
Found CMake: /usr/local/bin/cmake (3.24.3)
Run-time dependency rz_core found: YES 0.4.1
Run-time dependency rz_util found: YES 0.4.1
Run-time dependency rz_cons found: YES 0.4.1
Run-time dependency rz_config found: YES 0.4.1
Run-time dependency rz_io found: YES 0.4.1
Library m found: YES
Configuring jsdec_jsc.c using configuration
Message: Rizin Plugin Dir: /usr/local/lib/rizin/plugins/jsdec
Message: JS to C Folder: ..
Build targets in project: 1

Found ninja-1.11.1 at /usr/local/bin/ninja
ninja: Entering directory build' [4/4] Linking target libcore_pdd.dylib Installing jsdec... ninja: Entering directory build'
ninja: no work to do.
Installing libcore_pdd.dylib to /usr/local/lib/rizin/plugins
Package jsdec built and installed.

Many thanks!!

@ret2libc ret2libc closed this as completed Jan 4, 2023
@ret2libc
Copy link
Member

ret2libc commented Jan 4, 2023

Perfect! Glad it helped ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants