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

Fails to build on Mac OS Catalina 10.15.3 #197

Open
kpewing opened this issue Feb 11, 2020 · 5 comments
Open

Fails to build on Mac OS Catalina 10.15.3 #197

kpewing opened this issue Feb 11, 2020 · 5 comments

Comments

@kpewing
Copy link

kpewing commented Feb 11, 2020

hammer fails to build on Mac OS Catalina 10.15.3. It seems to be pointer incompatibilities created when managing vasprint() on BSD-like systems.

(master *) > scons -Q --debug=findlibs
clang -o build/opt/src/platform_bsdlike.os -c -std=c99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-attributes -Wno-unused-variable -O3 -fPIC -D_POSIX_C_SOURCE=200809L build/opt/src/platform_bsdlike.c
build/opt/src/platform_bsdlike.c:33:19: error: incompatible pointer types
      passing 'char **' to parameter of type 'char *'; dereference with *
      [-Werror,-Wincompatible-pointer-types]
  return vsprintf(strp, fmt, arg);
                  ^~~~
                  *
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:66:29: note:
      expanded from macro 'vsprintf'
  __builtin___vsprintf_chk (str, 0, __darwin_obsz(str), format, ap)
                            ^~~
1 error generated.
scons: *** [build/opt/src/platform_bsdlike.os] Error 1
@pesco
Copy link

pesco commented Feb 12, 2020

clang [...] build/opt/src/platform_bsdlike.c
build/opt/src/platform_bsdlike.c:33:19: error: incompatible pointer types
passing 'char **' to parameter of type 'char *'; dereference with *
[-Werror,-Wincompatible-pointer-types]
return vsprintf(strp, fmt, arg);

That is not what is supposed to be on line 33 of platform_bsdlike.c. That line is (and has been):

return vasprintf(strp, fmt, arg);

https://github.com/UpstandingHackers/hammer/blob/master/src/platform_bsdlike.c#L33

@kpewing
Copy link
Author

kpewing commented Feb 12, 2020

Thanks for checking so quickly. I started over, deleting and reinstalling with git clone but still get the following error (skipping successful builds of various other targets):

(master) > scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...

...

build/opt/src/platform_bsdlike.c:33:10: error: implicit declaration of function
      'vasprintf' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  return vasprintf(strp, fmt, arg);
         ^
build/opt/src/platform_bsdlike.c:33:10: note: did you mean 'vsprintf'?
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h:192:6: note: 
      'vsprintf' declared here
int      vsprintf(char * __restrict, const char * __restrict, va_list) _...
         ^
1 error generated.
scons: *** [build/opt/src/platform_bsdlike.os] Error 1
scons: building terminated because of errors.

@pesco
Copy link

pesco commented Feb 13, 2020 via email

@kpewing
Copy link
Author

kpewing commented Feb 13, 2020

Tried various variations on your suggestion, but no go. (See attached tries.txt.)
tries.txt.

How about this explanation, instead? We're not seeing vasprint() because we're calling clang with -D_POSIX_C_SOURCE=200809L. My argument is that /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h defines vasprint at line 377, which requires __DARWIN_C-LEVEL >= __DARWIN_C_FULL. These, in turn, are defined in ...sys/cdefs.h (hat tip John Haskell at https://stackoverflow.com/questions/32803754/what-is-the-darwin-c-level-c-preprocessor-symbol), which specifies __DARWIN_C_FULL (only) if neither __DARWIN_C_ANSI nor _POSIX_C_SOURCE has been defined. Since we're specifying a _POSIX_C_SOURCE level, we don't have __DARWIN_C_FULL and no vasprint().

@pesco
Copy link

pesco commented Feb 17, 2020

That sounds about right. Thanks for investigating! FYI, there is a new repo where Hammer work is currently happening. I've opened an issue there.

https://gitlab.special-circumstanc.es/hammer/hammer/issues/93

For reference, your immediate workaround is to remove that define from the global flags (in SConstruct) and place it as a #define at the very top of src/registry.c where it came from (cf. 321600b).

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

2 participants