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

Compiling on musl system #582

Closed
FallingSnow opened this issue May 10, 2022 · 6 comments
Closed

Compiling on musl system #582

FallingSnow opened this issue May 10, 2022 · 6 comments

Comments

@FallingSnow
Copy link

Running into an issue on alpine linux. Can't seem to find sys/pci.h while compiling. Cloned from master branch.

See https://bugs.gentoo.org/713610 for additional info.

$ uname -a
Linux master1.node.universalis.dev 5.15.37-0-lts #1-Alpine SMP Tue, 03 May 2022 11:42:03 +0000 x86_64 Linux
$ git rev-parse origin/master
5b34f7a86d0b5862b0e6d5cfaf06869a85b466cb
mtcr_ul_com.c:80:10: fatal error: sys/pci.h: No such file or directory
   80 | #include <sys/pci.h>
      |          ^~~~~~~~~~~
compilation terminated.
make[2]: *** [Makefile:617: libmtcr_ul_a-mtcr_ul_com.o] Error 1
make[2]: *** Waiting for unfinished jobs....
mv -f .deps/libmtcr_ul_a-mtcr_mem_ops.Tpo .deps/libmtcr_ul_a-mtcr_mem_ops.Po
mv -f .deps/libmtcr_ul_a-mtcr_ib_res_mgt.Tpo .deps/libmtcr_ul_a-mtcr_ib_res_mgt.Po
mv -f .deps/libmtcr_ul_a-packets_layout.Tpo .deps/libmtcr_ul_a-packets_layout.Po
mv -f .deps/libmtcr_ul_a-packets_common.Tpo .deps/libmtcr_ul_a-packets_common.Po
mv -f .deps/libmtcr_ul_a-mtcr_ul.Tpo .deps/libmtcr_ul_a-mtcr_ul.Po
mv -f .deps/libmtcr_ul_a-mtcr_tools_cif.Tpo .deps/libmtcr_ul_a-mtcr_tools_cif.Po
mv -f .deps/libmtcr_ul_a-mtcr_ul_icmd_cif.Tpo .deps/libmtcr_ul_a-mtcr_ul_icmd_cif.Po
make[2]: Leaving directory '/root/mstflint/mtcr_ul'
make[1]: *** [Makefile:551: all-recursive] Error 1
make[1]: Leaving directory '/root/mstflint'
make: *** [Makefile:438: all] Error 2
@tomer540
Copy link
Contributor

Dear FallingSnow
mstflint does not support alpine linux release.
your missing file sys/pci.h is a mandatory system file require for the tools to work.

to get the missing file you can try to install a 3rd party package that contains it, like:
https://alpine.pkgs.org/3.15/alpine-main-x86_64/syslinux-dev-6.04_pre1-r9.apk.html

@FallingSnow
Copy link
Author

FallingSnow commented May 17, 2022

I know, but it's the system I have :(
I've tried installing syslinux-dev but the error persists.

$ apk list --installed | grep syslinux
syslinux-dev-6.04_pre1-r9 x86_64 {syslinux} (GPL-2.0-or-later) [installed]

$ ls /usr/share/syslinux/com32/include/sys/pci.h -l
-rw-r--r--    1 root     root          4299 Apr 13  2021 /usr/share/syslinux/com32/include/sys/pci.h

I tried that earlier when I found it via https://pkgs.alpinelinux.org/contents?file=pci.h&path=*%2Fsys&name=&branch=v3.15&arch=x86_64. Maybe my includes are wrong?

@tomer540
Copy link
Contributor

did you add the installation path to your $PATH variables so the compiler #include can see it?

@FallingSnow
Copy link
Author

I tried adding it to PATH

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/share/syslinux
$ git clone --depth=1 https://github.com/Mellanox/mstflint.git
...
$ cd mstflint
$ ./autogen.sh
...
$ ./configure --disable-inband
...
$ make -j24
...
mtcr_ul_com.c:80:10: fatal error: sys/pci.h: No such file or directory
   80 | #include <sys/pci.h>
      |          ^~~~~~~~~~~
compilation terminated.

Same error.

@acaos
Copy link

acaos commented May 19, 2022

These were the only changes I needed to make to compile on musl (after installing linux-headers and openssl-dev and compiling with --disable-inband):

diff -ur mstflint-4.20.0-orig/mtcr_ul/mtcr_ul_com.c mstflint-4.20.0/mtcr_ul/mtcr_ul_com.c
--- mstflint-4.20.0-orig/mtcr_ul/mtcr_ul_com.c  2022-04-28 11:50:04.000000000 +0000
+++ mstflint-4.20.0/mtcr_ul/mtcr_ul_com.c       2022-05-19 14:06:49.479797274 +0000
@@ -67,7 +67,13 @@
 #include <endian.h>
 #include <byteswap.h>
 #include <errno.h>
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
 #include <sys/types.h>
+#undef _GNU_SOURCE
+#else
+#include <sys/types.h>
+#endif
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <string.h>
@@ -77,7 +83,7 @@

 #if CONFIG_ENABLE_MMAP
 #include <sys/mman.h>
-#include <sys/pci.h>
+#include <linux/pci.h>
 #include <sys/ioctl.h>
 #endif

@FallingSnow
Copy link
Author

@acaos That worked perfectly. Thank you!

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