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

Portability fixes #669

Closed
wants to merge 5 commits into from
Closed

Portability fixes #669

wants to merge 5 commits into from

Conversation

Artturin
Copy link

@Artturin Artturin commented Jul 6, 2024

Better errors if something is missing

Not all platforms need 'dl' so use CMAKE_DL_LIBS which is set depending on
if its needed

Find threads with in a platform agnostic way which requires bumping
cmake_minimum_required to 3.10.

@Artturin Artturin mentioned this pull request Jul 6, 2024
@Artturin Artturin force-pushed the nixoscompat1 branch 3 times, most recently from f1dadf9 to 820ee8e Compare July 6, 2024 22:07
Artturin added 5 commits July 7, 2024 01:09
Better errors if something is missing

Not all platforms need 'dl' so use `CMAKE_DL_LIBS` which is set depending on
if its needed

Find threads with in a platform agnostic way which requires bumping
`cmake_minimum_required` to 3.10.
@Artturin Artturin changed the title Use pkg_search_module to find libraries, Use CXX variable and don't use a absolute path to echo, optional example scripts Portability fixes Jul 6, 2024

pkg_search_module(PCRE REQUIRED libpcre)
pkg_search_module(JSONC REQUIRED json-c)
pkg_search_module(LIBGC REQUIRED bdw-gc-threaded bdw-gc)
Copy link
Contributor

@ilyash-b ilyash-b Jul 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never tested bdw-gc. Did you? If not, let's remove it.

Edit: if keeping, there should be automated tests.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bdw-gc builds with threading by default, only freebsd separates the threaded and non threaded versions.

Comment on lines +85 to +87
file(READ lib/stdlib.ngs FILE_CONTENTS)
string(REPLACE "#@INSTALL_LIBDIR@" ${CMAKE_INSTALL_LIBDIR}/ngs FILE_CONTENTS "${FILE_CONTENTS}")
file(WRITE lib/stdlib.ngs "${FILE_CONTENTS}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would really prefer passing CMAKE_INSTALL_LIBDIR to the C code and then exposing it into the language instead of this.

Copy link
Contributor

@ilyash-b ilyash-b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the following error on Mac:

[ 64%] Building C object CMakeFiles/ngs.dir/compile.c.o
[ 71%] Building C object CMakeFiles/ngs.dir/debug.c.o
[ 78%] Building C object CMakeFiles/ngs.dir/ast.c.o
[ 85%] Building C object CMakeFiles/ngs.dir/malloc.c.o
[ 92%] Building C object CMakeFiles/ngs.dir/decompile.c.o
[100%] Linking C executable ngs
ld: library 'gc' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [ngs] Error 1
make[2]: *** [CMakeFiles/ngs.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [build] Error 2

I don't know why this happens.

@ilyash-b
Copy link
Contributor

While working on another issue discovered that this also happens when I comment out link_directories(/usr/local/lib /opt/homebrew/lib) in CMakeLists.txt

@Artturin
Copy link
Author

Artturin commented Jul 10, 2024

I'll split out the dependency part and ngs_path so the other improvements aren't blocked

@ilyash-b
Copy link
Contributor

Worked on #668 and had to make some changes. I took some of your changes here to the dev branch. Please rebase.

ilyash-b added a commit that referenced this pull request Jul 11, 2024
ilyash-b added a commit that referenced this pull request Jul 11, 2024
ilyash-b added a commit that referenced this pull request Jul 11, 2024
ilyash-b added a commit that referenced this pull request Jul 11, 2024
ilyash-b added a commit that referenced this pull request Jul 11, 2024
ilyash-b added a commit that referenced this pull request Jul 11, 2024
ilyash-b added a commit that referenced this pull request Jul 11, 2024
ilyash-b added a commit that referenced this pull request Jul 11, 2024
ilyash-b added a commit that referenced this pull request Jul 11, 2024
@ilyash-b
Copy link
Contributor

I have pulled your changes from this PR piece by piece into dev. Can you please take a look if I missed something? If everything is OK, you can close this PR.

I've modified string replacement to passing CMAKE_INSTALL_FULL_LIBDIR to the C code and from there to NGS_PATH.

@Artturin
Copy link
Author

I have pulled your changes from this PR piece by piece into dev. Can you please take a look if I missed something? If everything is OK, you can close this PR.

I've modified string replacement to passing CMAKE_INSTALL_FULL_LIBDIR to the C code and from there to NGS_PATH.

Awesome, thank you. There is one change missing. #671

@Artturin Artturin closed this Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants