open-mpi / hwloc

Hardware locality (hwloc)
https://www.open-mpi.org/projects/hwloc
Other
577 stars 174 forks source link

build hwloc 2.11.1 on old suse 9: undefined reference to `hwloc_accessat' #676

Closed zhchgbj closed 3 months ago

zhchgbj commented 4 months ago

What version of hwloc are you using?

2.11.1

Which operating system and hardware are you running on?

I'm using my old box of suse 9 to build hwloc 2.11.1.

ff75ff964fbd:/data/code/3rd/hwloc/build/hwloc-2.11.1/linux2.6-glibc2.3-x86_64 # uname -a
Linux ff75ff964fbd 5.14.0-427.22.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jun 10 09:23:36 EDT 2024 x86_64 x86_64 x86_64 GNU/Linux
ff75ff964fbd:/data/code/3rd/hwloc/build/hwloc-2.11.1/linux2.6-glibc2.3-x86_64 # cat /etc/*release
LSB_VERSION="core-2.0-noarch:core-3.0-noarch:core-2.0-x86_64:core-3.0-x86_64"
SUSE LINUX Enterprise Server 9 (x86_64)
VERSION = 9
PATCHLEVEL = 4

Details of the problem

When run make, it report hwloc_accessat not defined.

  CC       topology-linux.lo                                                                                                                                
  CC       topology-hardwired.lo                                                                                                                            
  CC       topology-x86.lo                                                                                                                                  
topology-linux.c: In function `hwloc_find_linux_cgroup_mntpnt':                                                                                             
topology-linux.c:2290: warning: implicit declaration of function `hwloc_accessat'                                                                           
  CCLD     libhwloc.la                                                                                                                                      
make[1]: Leaving directory `/data/code/3rd/hwloc/build/hwloc-2.11.1/linux2.6-glibc2.3-x86_64/hwloc'                                                         
Making all in utils                                                                                                                                         
make[1]: Entering directory `/data/code/3rd/hwloc/build/hwloc-2.11.1/linux2.6-glibc2.3-x86_64/utils'                                                        
Making all in hwloc                                                                                                                                         
make[2]: Entering directory `/data/code/3rd/hwloc/build/hwloc-2.11.1/linux2.6-glibc2.3-x86_64/utils/hwloc'                                                  
Making all in .                                                                                                                                             
make[3]: Entering directory `/data/code/3rd/hwloc/build/hwloc-2.11.1/linux2.6-glibc2.3-x86_64/utils/hwloc'                                                  
  CC       hwloc-annotate.o       
...

  CCLD     hwloc-info                                                                                                                                       
  CCLD     hwloc-patch                                                                                                                                      
   File `hwloc-gather-cpuid' does not exist.                                                                                                                
  Must remake target `hwloc-gather-cpuid'.                                                                                                                  
  CCLD     hwloc-ps                                                                                                                                         
/data/code/3rd/hwloc/build/hwloc-2.11.1/linux2.6-glibc2.3-x86_64/hwloc/.libs/libhwloc.so: undefined reference to `hwloc_accessat'                           
collect2: ld returned 1 exit status                                                                                                                         
/data/code/3rd/hwloc/build/hwloc-2.11.1/linux2.6-glibc2.3-x86_64/hwloc/.libs/libhwloc.so: undefined reference to `hwloc_accessat'                           
collect2: ld returned 1 exit status                                                                                                                         
/data/code/3rd/hwloc/build/hwloc-2.11.1/linux2.6-glibc2.3-x86_64/hwloc/.libs/libhwloc.so: undefined reference to `hwloc_accessat'                           
collect2: ld returned 1 exit status
/data/code/3rd/hwloc/build/hwloc-2.11.1/linux2.6-glibc2.3-x86_64/hwloc/.libs/libhwloc.so: undefined reference to `hwloc_accessat'
collect2: ld returned 1 exit status
make[3]: *** [hwloc-distrib] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: *** [hwloc-bind] Error 1

Additional information

zhchgbj commented 4 months ago

HAVE_OPENAT should not defined on my old suse 9, so

Paste my code diff:

# diff hwloc/topology-linux.c.orig hwloc/topology-linux.c
--- hwloc/topology-linux.c.orig 2024-07-18 04:01:23.966193672 -0400
+++ hwloc/topology-linux.c      2024-07-18 04:02:20.630314763 -0400
@@ -2288,15 +2288,15 @@

   /* try standard mount points */
-  if (!hwloc_accessat("/sys/fs/cgroup/cpuset.cpus.effective", R_OK, fsroot_fd)) {
+  if (!hwloc_access("/sys/fs/cgroup/cpuset.cpus.effective", R_OK, fsroot_fd)) {
     hwloc_debug("Found standard cgroup2/cpuset mount point at /sys/fs/cgroup/\n");
     *cgtype = HWLOC_LINUX_CGROUP2;
     *mntpnt = strdup("/sys/fs/cgroup");
     return;
-  } else if (!hwloc_accessat("/sys/fs/cgroup/cpuset/cpuset.cpus", R_OK, fsroot_fd)) {
+  } else if (!hwloc_access("/sys/fs/cgroup/cpuset/cpuset.cpus", R_OK, fsroot_fd)) {
     hwloc_debug("Found standard cgroup1/cpuset mount point at /sys/fs/cgroup/cpuset/\n");
     *cgtype = HWLOC_LINUX_CGROUP1;
     *mntpnt = strdup("/sys/fs/cgroup/cpuset");
     return;
-  } else if (!hwloc_accessat("/dev/cpuset/cpus", R_OK, fsroot_fd)) {
+  } else if (!hwloc_access("/dev/cpuset/cpus", R_OK, fsroot_fd)) {
     hwloc_debug("Found standard cpuset mount point at /dev/cpuset/\n");
     *cgtype = HWLOC_LINUX_CPUSET;