Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.6.7
    • Fix Version/s: JRuby 1.7.0.pre1
    • Component/s: C Extensions, Launcher
    • Labels:
    • Environment:
      OSX 10.8.0 (Snow Leopard) i386 Kernel
      GCC 4.6.3 (MacPorts provided)
    • Number of attachments :
      0

      Description

      When trying to install jruby-launcher gem, it fails with the following output:

      <pre>
      mkdir -p build/unix/Darwin
      rm -f build/unix/Darwin/argparser.o.d
      g++ -O2 -Wall -I/opt/local/include -c argparser.cpp -MMD -MP -MF build/unix/Darwin/argparser.o.d -o build/unix/Darwin/argparser.o
      argparser.cpp: In member function 'bool ArgParser::initPlatformDir()':
      argparser.cpp:126:15: error: 'MAX_PATH' was not declared in this scope
      argparser.cpp:130:40: warning: converting to non-pointer type 'char' from NULL [-Wconversion-null]
      argparser.cpp:131:17: error: 'path' was not declared in this scope
      argparser.cpp:150:44: error: 'path' was not declared in this scope
      argparser.cpp:155:40: error: 'path' was not declared in this scope
      argparser.cpp:181:17: error: 'path' was not declared in this scope
      argparser.cpp:187:16: error: 'path' was not declared in this scope
      argparser.cpp:196:17: error: 'path' was not declared in this scope
      argparser.cpp:201:16: error: 'path' was not declared in this scope
      make[2]: *** [build/unix/Darwin/argparser.o] Error 1
      make[1]: *** [.build-conf] Error 2
      make: *** [.build-impl] Error 2
      </pre>

      This works under Apple's GCC 4.2.1 (port select --set gcc gcc42).

        Activity

        Hide
        Charles Oliver Nutter added a comment -

        Here's a possible patch. It looks like there's no consistent way to get the maximum path length, so I try a couple constants. Can you see if this works for you?

        diff --git a/argparser.cpp b/argparser.cpp
        index ee42a16..24d45b3 100644
        --- a/argparser.cpp
        +++ b/argparser.cpp
        @@ -116,7 +116,11 @@ void ArgParser::addEnvVarToOptions(std::list<std::string> & optionsList, const c
         #endif
         
         #ifndef PATH_MAX
        -#define PATH_MAX  MAX_PATH
        +#  if defined(MAX_PATH)
        +#    define PATH_MAX MAX_PATH
        +#  else defined(MAXPATHLEN)
        +#    define PATH_MAX MAXPATHLEN
        +#  endif
         #endif
         
         bool ArgParser::initPlatformDir() {
        

        You could also check the limits.h header file for me to see if it has something defined we can use.

        Show
        Charles Oliver Nutter added a comment - Here's a possible patch. It looks like there's no consistent way to get the maximum path length, so I try a couple constants. Can you see if this works for you? diff --git a/argparser.cpp b/argparser.cpp index ee42a16..24d45b3 100644 --- a/argparser.cpp +++ b/argparser.cpp @@ -116,7 +116,11 @@ void ArgParser::addEnvVarToOptions(std::list<std::string> & optionsList, const c #endif #ifndef PATH_MAX -#define PATH_MAX MAX_PATH +# if defined(MAX_PATH) +# define PATH_MAX MAX_PATH +# else defined(MAXPATHLEN) +# define PATH_MAX MAXPATHLEN +# endif #endif bool ArgParser::initPlatformDir() { You could also check the limits.h header file for me to see if it has something defined we can use.
        Hide
        Luis Lavena added a comment -

        Well, just by including limits.h before any MAX_PATH and PATH_MAX solves the issue.

        And by including it has no effect on GCC 4.2.

        Haven't tested if this works on Windows, but I guess it will.

        Show
        Luis Lavena added a comment - Well, just by including limits.h before any MAX_PATH and PATH_MAX solves the issue. And by including it has no effect on GCC 4.2. Haven't tested if this works on Windows, but I guess it will.
        Hide
        Charles Oliver Nutter added a comment -

        Ahh well there ya go. We must have been inheriting limits.h from some file that has changed in updated gcc.

        I'll add the include and we should be good.

        Show
        Charles Oliver Nutter added a comment - Ahh well there ya go. We must have been inheriting limits.h from some file that has changed in updated gcc. I'll add the include and we should be good.
        Hide
        Charles Oliver Nutter added a comment -

        Fixed! We need to do a release of jruby-launcher, though.

        commit 5ff9e9213dbf47013ccb186c5dda35846269c09f
        Author: Charles Oliver Nutter <headius@headius.com>
        Date:   Fri May 18 10:36:45 2012 -0500
        
            Fix JRUBY-6671
            
            jruby-launcher fails to compile with GCC 4.6.3 on OSX
            
            Added include of <limits> to get PATH_MAX/MAX_PATH defined.
        
        Show
        Charles Oliver Nutter added a comment - Fixed! We need to do a release of jruby-launcher, though. commit 5ff9e9213dbf47013ccb186c5dda35846269c09f Author: Charles Oliver Nutter <headius@headius.com> Date: Fri May 18 10:36:45 2012 -0500 Fix JRUBY-6671 jruby-launcher fails to compile with GCC 4.6.3 on OSX Added include of <limits> to get PATH_MAX/MAX_PATH defined.

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            Luis Lavena
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: