Opened 9 years ago

Closed 9 years ago

#47498 closed defect (fixed)

gpsd @3.14: error: redefinition of typedef 'clockid_t'

Reported by: thyAnger Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone:
Component: ports Version: 2.3.3
Keywords: snowleopard haspatch Cc: StanSanderson, dliessi (Davide Liessi)
Port: gpsd

Description

sudo port upgrade outdated

lead to

Error: org.macports.build for port gpsd returned: command execution failed

on iMac 24 inch, sept.2006 with snow leopard.

Attached please you find the log.

Attachments (3)

main.log (21.2 KB) - added by thyAnger 9 years ago.
patch-SConstruct.diff (2.3 KB) - added by jmroot (Joshua Root) 9 years ago.
Portfile.diff (577 bytes) - added by jmroot (Joshua Root) 9 years ago.

Download all attachments as: .zip

Change History (21)

Changed 9 years ago by thyAnger

Attachment: main.log added

comment:1 Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)

Keywords: snowleopard added; gpsd removed
Owner: changed from macports-tickets@… to ryandesign@…
Port: gpsd added
Status: newassigned
Summary: gpsd fail to buildgpsd @3.14: error: redefinition of typedef 'clockid_t'

Snow Leopard-specific problem. Builds fine on Lion and later. I emailed the developer about this on 4/15/2015 but haven't heard back. There is a gpsd mailing list. Maybe posting there would get a response. Would you like to do that?

comment:2 Changed 9 years ago by scooter.phd@…

Depends on which Mountain Lion and what your default clang happens to be. If it happens to be clang-3.7-mp, the compiler will complain that clock_t is a C++11 feature, which is not enabled by default.

comment:3 in reply to:  1 Changed 9 years ago by thyAnger

Replying to ryandesign@…:

Snow Leopard-specific problem. Builds fine on Lion and later. I emailed the developer about this on 4/15/2015 but haven't heard back. There is a gpsd mailing list. Maybe posting there would get a response. Would you like to do that?

Sorry for the delay. Ok I will try on that mailing list and let you know.

Regards.

comment:4 Changed 9 years ago by StanSanderson

Cc: stansand@… added

Cc Me!

comment:5 Changed 9 years ago by dliessi (Davide Liessi)

Cc: davide.liessi@… added

Cc Me!

comment:6 Changed 9 years ago by dliessi (Davide Liessi)

I tried compiling with sudo port upgrade gpsd configure.compiler=clang as suggested by Ryan here and still got an error about clockid_t.

This is the relevant part of main.log:

:info:build In file included from ais_json.c:23:
:info:build In file included from ./libgps.h:13:
:info:build In file included from ./compiler.h:23:
:info:build ./gpsd_config.h:305:13: error: redefinition of typedef 'clockid_t' is invalid in C [-Wtypedef-redefinition]
:info:build typedef int clockid_t;
:info:build             ^
:info:build In file included from ais_json.c:19:
:info:build ./gpsd_config.h:305:13: note: previous definition is here
:info:build typedef int clockid_t;
:info:build             ^
:info:build 1 error generated.
:info:build scons: *** [ais_json.os] Error 1
:info:build scons: building terminated because of errors.
:info:build Command failed:  cd "/opt/local/var/macports/build/_opt_macports-git_trunk_dports_net_gpsd/gpsd/work/gpsd-3.14" && /opt/local/bin/scons -j2 prefix=/opt/local libQgpsmm=no usb=no strip=no 
:info:build Exit code: 2

comment:7 Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)

Oh. I was hoping it was just a compiler problem. And on my Yosemite system, I was able to reproduce the error if build gpsd with MacPorts gcc 4.3, 4.4, or 4.5, but it built fine with gcc 4.6, 4.7 and 4.8.

Using clang on Yosemite, a warning is emitted instead:

./gpsd_config.h:303:13: warning: redefinition of typedef 'clockid_t' is a C11 feature [-Wtypedef-redefinition]
typedef int clockid_t;
            ^
./gpsd_config.h:303:13: note: previous definition is here
typedef int clockid_t;
            ^
1 warning generated.

I'll ask the developer if the code can be changed so that there are no redefinitions.

comment:8 in reply to:  7 Changed 9 years ago by dliessi (Davide Liessi)

Replying to ryandesign@…:

[...] but it built fine with gcc 4.6, 4.7 and 4.8.

I'll try with one of those versions.

I'll ask the developer if the code can be changed so that there are no redefinitions.

This would be the best solution, of course.

comment:9 Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)

You should not try to install with a MacPorts gcc version; that will use a different C++ library than the rest of your software and could lead to crashes. I was only testing it to get information to give to the developer.

comment:10 Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)

I suspect the old version of clang included in Xcode 3.2.6 does not know C11 either. You could try installing a newer version of clang from MacPorts (clang-3.4 for example), then building with that:

sudo port install clang-3.4
sudo port clean gpsd
sudo port upgrade gpsd configure.compiler=macports-clang-3.4

If you already have a different version of clang installed with MacPorts you could try that.

comment:11 Changed 9 years ago by dliessi (Davide Liessi)

Installation fails with MacPorts gcc 4.7 and 4.8, with the same error but in a different file:

:info:build /opt/local/bin/gcc-mp-4.8 -m64 -o monitor_garmin.o -c -Os -m64 -Wextra -Wall -Wno-uninitialized -Wno-missing-field-initializers -Wcast-align -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith -Wreturn-type -pthread -Wmissing-declarations -O2 -I/opt/local/include/dbus-1.0 -I/opt/local/lib/dbus-1.0/include -I/opt/local/include monitor_garmin.c
:info:build /usr/bin/gcc-4.2 -o gpsclient-py_2_7_9_final_0.so -c -fno-strict-aliasing -fno-common -dynamic -Wmissing-declarations -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 gpsclient.c
:info:build /opt/local/bin/gcc-mp-4.8 -m64 -o gpsmon gpsmon.o monitor_italk.o monitor_nmea0183.o monitor_oncore.o monitor_sirf.o monitor_superstar2.o monitor_tnt.o monitor_ubx.o monitor_garmin.o -L. -L/opt/local/lib -ldbus-1 -lgpsd -lgps -ldbus-1 -lncurses -lm
:info:build /usr/bin/gcc-4.2 -o gpsdclient-py_2_7_9_final_0.so -c -fno-strict-aliasing -fno-common -dynamic -Wmissing-declarations -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 gpsdclient.c
:info:build /usr/bin/gcc-4.2 -o geoid-py_2_7_9_final_0.so -c -fno-strict-aliasing -fno-common -dynamic -Wmissing-declarations -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 geoid.c
:info:build In file included from compiler.h:23,
:info:build                  from gpsd.h:353,
:info:build                  from geoid.c:12:
:info:build gpsd_config.h:303: error: redefinition of typedef 'clockid_t'
:info:build gpsd.h:323: error: previous declaration of 'clockid_t' was here
:info:build scons: *** [geoid-py_2_7_9_final_0.so] Error 1
:info:build scons: building terminated because of errors.
:info:build Command failed:  cd "/opt/local/var/macports/build/_opt_macports-git_trunk_dports_net_gpsd/gpsd/work/gpsd-3.14" && /opt/local/bin/scons -j2 prefix=/opt/local libQgpsmm=no usb=no strip=no 
:info:build Exit code: 2

I included also some lines of the log before the error, to show that although I specified configure.compiler=macports-gcc-4.8, the build script used /usr/bin/gcc-4.2 on three files and the error happened in one of those files.

Maybe SCons is not obeying the compiler setting?

I'm trying with macports-clang-3.4 now.


that will use a different C++ library than the rest of your software and could lead to crashes

Is this only hypothetical or is it a real risk? I actually installed a couple of ports with macports-gcc-4.7 or macports-gcc-4.8, because they wouldn't build otherwise.

comment:12 Changed 9 years ago by dliessi (Davide Liessi)

I'm trying with macports-clang-3.4 now.

I got 73 warnings of the type

:info:build ./gpsd_config.h:303:13: warning: redefinition of typedef 'clockid_t' is a C11 feature [-Wtypedef-redefinition]
:info:build typedef int clockid_t;
:info:build             ^
:info:build ./gpsd_config.h:303:13: note: previous definition is here
:info:build typedef int clockid_t;
:info:build             ^

all resulting from invocations of /opt/local/bin/clang-mp-3.4.

Then I got this:

:info:build /usr/bin/gcc-4.2 -o gpsclient-py_2_7_9_final_0.so -c -fno-strict-aliasing -fno-common -dynamic -Wmissing-declarations -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 gpsclient.c
:info:build /opt/local/bin/clang-mp-3.4 -arch x86_64 -o gpsmon gpsmon.o monitor_italk.o monitor_nmea0183.o monitor_oncore.o monitor_sirf.o monitor_superstar2.o monitor_tnt.o monitor_ubx.o monitor_garmin.o -L. -L/opt/local/lib -ldbus-1 -lgpsd -lgps -ldbus-1 -lncurses -lm
:info:build /usr/bin/gcc-4.2 -o geoid-py_2_7_9_final_0.so -c -fno-strict-aliasing -fno-common -dynamic -Wmissing-declarations -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 geoid.c
:info:build In file included from compiler.h:23,
:info:build                  from gpsd.h:353,
:info:build                  from geoid.c:12:
:info:build gpsd_config.h:303: error: redefinition of typedef 'clockid_t'
:info:build gpsd.h:323: error: previous declaration of 'clockid_t' was here
:info:build scons: *** [geoid-py_2_7_9_final_0.so] Error 1
:info:build scons: building terminated because of errors.
:info:build Command failed:  cd "/opt/local/var/macports/build/_opt_macports-git_trunk_dports_net_gpsd/gpsd/work/gpsd-3.14" && /opt/local/bin/scons -j2 prefix=/opt/local libQgpsmm=no usb=no strip=no 
:info:build Exit code: 2

I'm convinced that there are two problems here: the first is that clockid_t should not be redefined, the second is that SCons does not choose the desired compiler. I don't know SCons, but I read that it does not automatically obey CC, CXX, ... environment variables, so probably both problems need to be solved upstream.

comment:13 Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)

Ok, so it probably is just a compiler problem (or rather, that the project is using C11 features that older compilers don't understand), and additionally there is the problem that the port isn't using the compiler you requested in all cases.

Yes, scons needs to be told to use the compiler via CC, CXX environment variables. The port already does that. But apparently in some cases, a different compiler—your system default gcc-4.2—is used. I notice that the lines where gcc-4.2 is used also deal with python, so I suspect this is happening because the python27 port was installed with gcc-4.2, and it remembered that, and recorded it somewhere, and is now using that for these files. Ideally we should stop that from happening but I will have to look at the build system for awhile to see why it's happening.

comment:14 Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)

Oh wait, you said "SCons [...] does not automatically obey CC, CXX, ... environment variables". Well, it depends. It's up to each project to implement it themselves. gpsd has implemented support for the CC and CXX environment variables, and the port sets them, and it works—except, as you've found, for those files that are using python, so we have to deal with that now.

comment:15 Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)

Fixed the build system in r135694 to use the right compiler and arch flags for building the python module. Now (after you wait 30 minutes and then run "sudo port selfupdate") overriding the compiler as in comment:10 should hopefully work.

comment:16 Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: fixed
Status: assignedclosed

Blacklisted old gcc in r135698. Blacklisted Xcode 3's clang in r135699. If you still encounter this error after selfupdating, we may need to blacklist additional compilers; let me know.

comment:17 Changed 9 years ago by jmroot (Joshua Root)

Keywords: haspatch added
Resolution: fixed
Status: closedreopened

Someone forgot that #define and typedef are not the same thing.

#ifndef clockid_t
typedef int clockid_t;
# endif

Changed 9 years ago by jmroot (Joshua Root)

Attachment: patch-SConstruct.diff added

Changed 9 years ago by jmroot (Joshua Root)

Attachment: Portfile.diff added

comment:18 Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: fixed
Status: reopenedclosed

Thanks! I knew there had to be a simple solution. I'll pass that on to the developer. Committed in r135706.

Note: See TracTickets for help on using tickets.