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

Fix libnereon build on msys2 #421

Open
ribose-jeffreylau opened this issue Dec 29, 2021 · 9 comments
Open

Fix libnereon build on msys2 #421

ribose-jeffreylau opened this issue Dec 29, 2021 · 9 comments
Assignees

Comments

@ribose-jeffreylau
Copy link
Contributor

https://github.com/riboseinc/retrace/runs/4656054619?check_suite_focus=true#step:5:384

Makefile has not been generated at all.

-- Build files have been written to: D:/a/retrace/retrace/libnereon/build
+ ls -la
total 102
drwxr-xr-x 1 runneradmin None     0 Dec 29 05:49 .
drwxr-xr-x 1 runneradmin None     0 Dec 29 05:49 ..
+ ls -la ..
-rw-r--r-- 1 runneradmin None 60014 Dec 29 05:49 build.ninja
-rw-r--r-- 1 runneradmin None  1931 Dec 29 05:49 cmake_install.cmake
-rw-r--r-- 1 runneradmin None 16458 Dec 29 05:49 CMakeCache.txt
drwxr-xr-x 1 runneradmin None     0 Dec 29 05:49 CMakeFiles
-rw-r--r-- 1 runneradmin None   337 Dec 29 05:49 CTestTestfile.cmake
drwxr-xr-x 1 runneradmin None     0 Dec 29 05:49 libucl
drwxr-xr-x 1 runneradmin None     0 Dec 29 05:49 libucl-inst
drwxr-xr-x 1 runneradmin None     0 Dec 29 05:49 libucl-prefix
-rw-r--r-- 1 runneradmin None    70 Dec 29 05:49 nereon_config.h
drwxr-xr-x 1 runneradmin None     0 Dec 29 05:49 src
drwxr-xr-x 1 runneradmin None     0 Dec 29 05:49 tests
drwxr-xr-x 1 runneradmin None     0 Dec 29 05:49 tools
total 35
drwxr-xr-x 1 runneradmin None    0 Dec 29 05:49 .
drwxr-xr-x 1 runneradmin None    0 Dec 29 05:49 ..
+ make
drwxr-xr-x 1 runneradmin None    0 Dec 29 05:49 .git
-rw-r--r-- 1 runneradmin None    8 Dec 29 05:49 .gitignore
-rw-r--r-- 1 runneradmin None  140 Dec 29 05:49 .travis.yml
drwxr-xr-x 1 runneradmin None    0 Dec 29 05:49 build
-rw-r--r-- 1 runneradmin None 1332 Dec 29 05:49 CMakeLists.txt
-rw-r--r-- 1 runneradmin None   94 Dec 29 05:49 nereon_config.h.in
-rw-r--r-- 1 runneradmin None 3107 Dec 29 05:49 README.md
drwxr-xr-x 1 runneradmin None    0 Dec 29 05:49 src
drwxr-xr-x 1 runneradmin None    0 Dec 29 05:49 tests
drwxr-xr-x 1 runneradmin None    0 Dec 29 05:49 tools
mingw32-make: *** No targets specified and no makefile found.  Stop.
@maxirmx
Copy link
Collaborator

maxirmx commented Jan 11, 2022

You install ninja so cmake uses ninja generator by default. There is build.ninja file that is essentially a makefile.
If you call

cmake --build  .

it will select correct build system that matches configure step

You can also do

cmake .. -G "Unix Makefiles" 

in order to get Makefile and not build.ninja

@maxirmx
Copy link
Collaborator

maxirmx commented Jan 11, 2022

There is a problem here: https://github.com/riboseinc/libnereon/blob/master/src/CMakeLists.txt

LIBNEREON_LIBRARY is not defined as CMake target at all. Unix and MacOS versions of cmake somehow manage to create correct build sequence, but MSYS version fails. So the fix is required at libneron source.

@maxirmx
Copy link
Collaborator

maxirmx commented Jan 11, 2022

Then there is an issue with RTLD_NEXT flag which is a bedrock of retrace technology. It is not POSIX and MSYS compilation with default settings considers it undefined

Probably

#define _GNU_SOURCE
#include <dlfcn.h>

can help but it needs to be tested as well

@maxirmx
Copy link
Collaborator

maxirmx commented Jan 13, 2022

If msys (=unix) environment is used for compilation it is essentially cygwin that does not support GNU extensions to dlsysm
So hooking with RTLD_NEXT does not compile and I did not find any port or extension

If mingw (=windows) environment is used for compilation, there is a package that pretends that it implements RTLD_NEXT -- https://packages.msys2.org/base/mingw-w64-dlfcn.
However, mingw lacks queue (https://man7.org/linux/man-pages/man7/queue.7.html) and may be some other GNU extensions.

So the only approach I see is to use mingw and adopt queue.h (I think it can be just dropped in).

I have to say that I am not MSYS expert so that all may be wrong.

@ribose-jeffreylau
Copy link
Contributor Author

So the only approach I see is to use mingw and adopt queue.h (I think it can be just dropped in).

Sounds like we can probably create a separate GitHub Action workflow for mingw to test this out, too.

@maxirmx
Copy link
Collaborator

maxirmx commented Jan 14, 2022

I do not know, can make assumptions only.
Now windows build looks like full scale project that requires some upfront experiments and research

ribose-jeffreylau added a commit that referenced this issue Jan 17, 2022
This commit re-uses build logic from libnereon's GHA scripts.

Related: #421
ribose-jeffreylau added a commit that referenced this issue Jan 17, 2022
This commit re-uses build logic from libnereon's GHA scripts.

Related: #421
ribose-jeffreylau added a commit that referenced this issue Jan 17, 2022
This commit re-uses build logic from libnereon's GHA scripts.

Related: #421
ribose-jeffreylau added a commit that referenced this issue Jan 17, 2022
This commit re-uses build logic from libnereon's GHA scripts.

Related: #421
ribose-jeffreylau added a commit that referenced this issue Jan 17, 2022
This commit re-uses build logic from libnereon's GHA scripts.

Related: #421

The link [1] was used in helping with the build issue (with libucl):

	aclocal-1.16: error: aclocal: file '/a/_temp/msys64/usr/share/aclocal/xsize.m4' does not exist

[1] kwhat/jnativehook#89
ribose-jeffreylau added a commit that referenced this issue Jan 17, 2022
This commit re-uses build logic from libnereon's GHA scripts.

Related: #421
ribose-jeffreylau added a commit that referenced this issue Jan 17, 2022
The link [1] was used in helping with the build issue (with libucl):

    aclocal-1.16: error: aclocal: file '/a/_temp/msys64/usr/share/aclocal/xsize.m4' does not exist

[1] kwhat/jnativehook#89

Related: #421
ribose-jeffreylau added a commit that referenced this issue Jan 17, 2022
The link [1] was used in helping with the build issue (with libucl):

    aclocal-1.16: error: aclocal: file '/a/_temp/msys64/usr/share/aclocal/xsize.m4' does not exist

[1] kwhat/jnativehook#89

Related: #421
ribose-jeffreylau added a commit that referenced this issue Jan 17, 2022
The links [1][2] were used in helping with the build issue (with libucl):

    aclocal-1.16: error: aclocal: file '/a/_temp/msys64/usr/share/aclocal/xsize.m4' does not exist

[1] kwhat/jnativehook#89
[2] avast/yaracpp#12

Related: #421
ribose-jeffreylau added a commit that referenced this issue Jan 17, 2022
This commit re-uses build logic from libnereon's GHA scripts.

Related: #421
ribose-jeffreylau added a commit that referenced this issue Jan 17, 2022
The links [1][2] were used in helping with the build issue (with libucl):

    aclocal-1.16: error: aclocal: file '/a/_temp/msys64/usr/share/aclocal/xsize.m4' does not exist

[1] kwhat/jnativehook#89
[2] avast/yaracpp#12

Related: #421
ribose-jeffreylau added a commit that referenced this issue Jan 17, 2022
The links [1][2] were used in helping with the build issue (with libucl):

    aclocal-1.16: error: aclocal: file '/a/_temp/msys64/usr/share/aclocal/xsize.m4' does not exist

However, setting ACLOCAL_PATH in the GitHub Action YAML would not work
as it would later get overridden to:
	/mingw64/share/aclocal:/usr/share/aclocal

[1] kwhat/jnativehook#89
[2] avast/yaracpp#12

Related: #421
ribose-jeffreylau added a commit that referenced this issue Jan 17, 2022
The links [1][2] were used in helping with the build issue (with libucl):

    aclocal-1.16: error: aclocal: file '/a/_temp/msys64/usr/share/aclocal/xsize.m4' does not exist

However, setting ACLOCAL_PATH in the GitHub Action YAML would not work
as it would later get overridden to:
	/mingw64/share/aclocal:/usr/share/aclocal

[1] kwhat/jnativehook#89
[2] avast/yaracpp#12

Related: #421
@maxirmx
Copy link
Collaborator

maxirmx commented Jan 18, 2022

Libnereon build fixed is here:
#427

@maxirmx
Copy link
Collaborator

maxirmx commented Jan 18, 2022

So the only approach I see is to use mingw and adopt queue.h (I think it can be just dropped in).

Sounds like we can probably create a separate GitHub Action workflow for mingw to test this out, too.

I made some tests locally. Mingw build fails fast because Windows SDK doeds not have Queue.h

@ribose-jeffreylau
Copy link
Contributor Author

Thanks @maxirmx ! This is good progress. I'll merge whatever we have now and figure the rest later.

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

Successfully merging a pull request may close this issue.

2 participants