The current Sconstruct only allows to compile using gcc, but not clang, which is the default compiler on newer versions of OS X. This applies both to 0.6.1 and HEAD.
I didn't like this patch because it determines either the gcc or the clang version and then uses them as if the two compilers have identical version histories, which they don't. For example, the script adds -fcoalesce-templates if the compiler version is less than 4. That's correct for gcc and incorrect for clang.
Instead my patch looks at the preprocessor macros. gcc defines __GNUC__ to the major version and __GNUC_MINOR__ to the minor version. gcc 3 and later also define __GNUC_PATCHLEVEL__ to the patch level but I ignored that here. clang defines __GNUC__ to 4, __GNUC_MINOR__ to 2, and __GNUC_PATCHLEVEL__ to 1 to indicate that it is compatible with gcc 4.2.1. My patch always gets the "gcc version" even when the compiler is clang. That way, the version comparisons that add flags, which are based on gcc version numbering, remain correct.
My patch also fixes a preexisting bug: it no longer adds flags intended for gcc < 4.2 when the gcc major version is greater than 4 and the minor version is less than 2.
I replaced popen3 with Popen because popen3 doesn't exist in Python 3. Additional changes are needed for Python 3 compatibility which I will submit in a separate ticket.
I didn't like this patch because it determines either the gcc or the clang version and then uses them as if the two compilers have identical version histories, which they don't. For example, the script adds
-fcoalesce-templatesif the compiler version is less than 4. That's correct for gcc and incorrect for clang.Instead my patch looks at the preprocessor macros. gcc defines
__GNUC__to the major version and__GNUC_MINOR__to the minor version. gcc 3 and later also define__GNUC_PATCHLEVEL__to the patch level but I ignored that here. clang defines__GNUC__to 4,__GNUC_MINOR__to 2, and__GNUC_PATCHLEVEL__to 1 to indicate that it is compatible with gcc 4.2.1. My patch always gets the "gcc version" even when the compiler is clang. That way, the version comparisons that add flags, which are based on gcc version numbering, remain correct.My patch also fixes a preexisting bug: it no longer adds flags intended for gcc < 4.2 when the gcc major version is greater than 4 and the minor version is less than 2.
I replaced
popen3withPopenbecausepopen3doesn't exist in Python 3. Additional changes are needed for Python 3 compatibility which I will submit in a separate ticket.Last edit: Ryan Carsten Schmidt 2023-03-09