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

regression caused by WEXITSTATUS: `nim cpp compiler/nim.nim` fails on OSX #10231

Closed
timotheecour opened this issue Jan 8, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@timotheecour
Copy link
Contributor

commented Jan 8, 2019

/cc @alaviss
this regression was probably caused by #10222

nim cpp compiler/nim.nim

Error: execution of an external compiler program 'clang++ -c  -w  -I/Users/timothee/git_clone/nim/Nim_devel/lib -I/Users/timothee/git_clone/nim/Nim_devel/compiler -o /tmp/d11/stdlib_os.cpp.o /tmp/d11/stdlib_os.cpp' failed with exit code: 1

/tmp/d11/stdlib_os.cpp:3079:8: error: cannot take the address of an rvalue of type 'int'
        T1_ = WEXITSTATUS(system(nimToCStringConv(command)));
              ^           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/sys/wait.h:144:26: note: expanded from macro 'WEXITSTATUS'
#define WEXITSTATUS(x)  ((_W_INT(x) >> 8) & 0x000000ff)
                          ^      ~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/sys/wait.h:131:28: note: expanded from macro '_W_INT'
#define _W_INT(w)       (*(int *)&(w))  /* convert union wait to int */
                                 ^ ~

note

to avoid further such regression, we should at least compile some compiler sources (eg maybe just nim cpp compiler/nim.nim) on CI / OSX

  • note: not sure if it's just OSX or other platforms

relevant snippet:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/sys/wait.h:

/*
 * Macros to test the exit status returned by wait
 * and extract the relevant values.
 */
#if defined(_POSIX_C_SOURCE) && !defined(_DARWIN_C_SOURCE)
#define	_W_INT(i)	(i)
#else
#define	_W_INT(w)	(*(int *)&(w))	/* convert union wait to int */
#define	WCOREFLAG	0200
#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */

/* These macros are permited, as they are in the implementation namespace */
#define	_WSTATUS(x)	(_W_INT(x) & 0177)
#define	_WSTOPPED	0177		/* _WSTATUS if process is stopped */

/*
 * [XSI] The <sys/wait.h> header shall define the following macros for
 * analysis of process status values
 */
#if __DARWIN_UNIX03
#define WEXITSTATUS(x)	((_W_INT(x) >> 8) & 0x000000ff)
#else /* !__DARWIN_UNIX03 */
#define WEXITSTATUS(x)	(_W_INT(x) >> 8)
#endif /* !__DARWIN_UNIX03 */

@timotheecour timotheecour changed the title regression caused by WEXITSTATUS: can't compile regression caused by WEXITSTATUS: `nim cpp compiler/nim.nim` fails on OSX Jan 8, 2019

@alaviss

This comment has been minimized.

Copy link
Contributor

commented Jan 8, 2019

Looks like POSIX compat is a mess on Darwin. I guess this could just be fixed with a special when branch.

alaviss added a commit to alaviss/Nim that referenced this issue Jan 8, 2019

os.execShellCmd: fixes nim-lang#10231
Darwin has long deprecated the wait union, but their macros still assume
it unless you define _POSIX_C_SOURCE. This trips up C++ compilers.

This commit duplicates the behavior of WEXITSTATUS when _POSIX_C_SOURCE
is defined.

@Araq Araq closed this in 6737634 Jan 8, 2019

@timotheecour

This comment has been minimized.

Copy link
Contributor Author

commented Jan 11, 2019

=> see PR #10274 that properly fixes this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.