Ticket 3528

Summary: undefined reference to `clock_gettime'
Product: Slurm Reporter: Kilian Cavalotti <kilian>
Component: slurmctldAssignee: Danny Auble <da>
Status: RESOLVED FIXED QA Contact:
Severity: 4 - Minor Issue    
Priority: ---    
Version: 16.05.10   
Hardware: Linux   
OS: Linux   
Site: Stanford Alineos Sites: ---
Atos/Eviden Sites: --- Confidential Site: ---
Coreweave sites: --- Cray Sites: ---
DS9 clusters: --- HPCnow Sites: ---
HPE Sites: --- IBM Sites: ---
NOAA SIte: --- OCF Sites: ---
Recursion Pharma Sites: --- SFW Sites: ---
SNIC sites: --- Linux Distro: ---
Machine Name: CLE Version:
Version Fixed: 16.05.10-2 17.02.1-2 Target Release: ---
DevPrio: --- Emory-Cloud Sites: ---

Description Kilian Cavalotti 2017-03-02 16:46:08 MST
Hi!

Just downloaded Slurm 16.05.10, started compiling RPMs (rpmbuild -ta slurm-16.05.10.tar.bz2), and it failed on:

slurm-16.05.10/src/slurmctld/agent.c:1282: undefined reference to `clock_gettime'

More context:

make[5]: Leaving directory `/root/rpmbuild/BUILD/slurm-16.05.10/src/common'
make[4]: Leaving directory `/root/rpmbuild/BUILD/slurm-16.05.10/src/api'
mv -f .deps/read_config.Tpo .deps/read_config.Po
mv -f .deps/trigger_mgr.Tpo .deps/trigger_mgr.Po
mv -f .deps/proc_req.Tpo .deps/proc_req.Po
mv -f .deps/reservation.Tpo .deps/reservation.Po
mv -f .deps/step_mgr.Tpo .deps/step_mgr.Po
mv -f .deps/job_mgr.Tpo .deps/job_mgr.Po
/bin/sh ../../libtool  --tag=CC   --mode=link gcc  -DNUMA_VERSION1_COMPATIBILITY -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -pthread -Wno-deprecated-declarations -Wall -g -O0 -fno-strict-aliasing -export-dynamic   -o slurmctld acct_policy.o agent.o backup.o burst_buffer.o controller.o front_end.o gang.o groups.o job_mgr.o job_scheduler.o job_submit.o licenses.o locks.o node_mgr.o node_scheduler.o partition_mgr.o ping_nodes.o port_mgr.o power_save.o powercapping.o preempt.o proc_req.o read_config.o reservation.o sched_plugin.o slurmctld_plugstack.o srun_comm.o state_save.o statistics.o step_mgr.o trigger_mgr.o ../../src/common/libdaemonize.la ../../src/api/libslurm.o -ldl
libtool: link: gcc -DNUMA_VERSION1_COMPATIBILITY -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -pthread -Wno-deprecated-declarations -Wall -g -O0 -fno-strict-aliasing -o slurmctld acct_policy.o agent.o backup.o burst_buffer.o controller.o front_end.o gang.o groups.o job_mgr.o job_scheduler.o job_submit.o licenses.o locks.o node_mgr.o node_scheduler.o partition_mgr.o ping_nodes.o port_mgr.o power_save.o powercapping.o preempt.o proc_req.o read_config.o reservation.o sched_plugin.o slurmctld_plugstack.o srun_comm.o state_save.o statistics.o step_mgr.o trigger_mgr.o ../../src/api/libslurm.o -Wl,--export-dynamic  ../../src/common/.libs/libdaemonize.a -ldl -pthread
agent.o: In function `_agent_init':
/root/rpmbuild/BUILD/slurm-16.05.10/src/slurmctld/agent.c:1282: undefined reference to `clock_gettime'
collect2: ld returned 1 exit status
make[3]: *** [slurmctld] Error 1
make[3]: Leaving directory `/root/rpmbuild/BUILD/slurm-16.05.10/src/slurmctld'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/root/rpmbuild/BUILD/slurm-16.05.10/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/rpmbuild/BUILD/slurm-16.05.10'
make: *** [all] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.T9LW9E (%build)


Cheers.
--
Kilian
Comment 1 Danny Auble 2017-03-02 17:13:38 MST
Hey Killian,

Sorry about that.  How old is your kernel?  This call was introduced in 2.6.

In any case, please go with this patch here...

diff --git a/src/slurmctld/agent.c b/src/slurmctld/agent.c
index 1ac6ffb..f8bd274 100644
--- a/src/slurmctld/agent.c
+++ b/src/slurmctld/agent.c
@@ -1279,8 +1279,7 @@ static void *_agent_init(void *arg)
                while (!slurmctld_config.shutdown_time &&
                       !pending_mail &&
                       (pending_wait_time == (uint16_t) NO_VAL)) {
-                       clock_gettime(CLOCK_REALTIME, &ts);
-                       ts.tv_sec += 5;
+                       ts.tv_sec  = time(NULL) + 5;
                        pthread_cond_timedwait(&pending_cond,&pending_mutex,&ts);
                }
                if (slurmctld_config.shutdown_time) {

It should get you going again.
Comment 2 Kilian Cavalotti 2017-03-02 17:25:13 MST
Hi Danny, 

We run CentOS 6.8, on kernel 2.6.32-573.22.1

The weird thing is that if I extract the tarball, run the same ./configure line than the .spec file does, and build, I don't see the error. Makes me feel the issue is likely more in a Makefile or the .spec file itself.
Comment 3 Kilian Cavalotti 2017-03-02 17:37:45 MST
Nope, I have to correct what I just wrote: I got the same error when compiling manually.

Actually, all that's missing is a "-lrt" flag in the LD options in the slurmctld Makefile:

--- src/slurmctld/Makefile.orig       2017-03-02 16:36:25.313295832 -0800
+++ src/slurmctld/Makefile    2017-03-02 16:36:01.239684559 -0800
@@ -277,7 +277,7 @@
 DEFS = -DHAVE_CONFIG_H
 DEPDIR = .deps
 DLLTOOL = false
-DL_LIBS = -ldl
+DL_LIBS = -ldl -lrt
 DSYMUTIL =
 DUMPBIN =
 ECHO_C =
Comment 4 Danny Auble 2017-03-02 18:05:13 MST
Ah, thanks for the update.  At least it makes sense.

For what it is worth I just ran through the rpm build (before the change) and it worked perfectly (16.05 and 17.02) for me on Ubuntu 16.10 and Centos 7, so I guess that extra lib isn't needed going forward.  In any case the call isn't that important, so we will just switch it as the patch I have shown commit .  It is the way we do it everywhere else so it should work just fine.

In any case I just tagged a (16.05.10 and 17.02.1)-2 version and posted it with this change.  Please let me know if you have any more issues.
Comment 5 Kilian Cavalotti 2017-03-02 18:48:01 MST
(In reply to Danny Auble from comment #4)
> For what it is worth I just ran through the rpm build (before the change)
> and it worked perfectly (16.05 and 17.02) for me on Ubuntu 16.10 and Centos
> 7, so I guess that extra lib isn't needed going forward.  In any case the
> call isn't that important, so we will just switch it as the patch I have
> shown commit .  It is the way we do it everywhere else so it should work
> just fine.
> 
> In any case I just tagged a (16.05.10 and 17.02.1)-2 version and posted it
> with this change.  Please let me know if you have any more issues.

Great! Grabbed the patch, compiled and installed. All is good so far.

Thanks!