Xcode 5's template-depth for g++/clang++ -- fix makefiles?

288 views
Skip to first unread message

Bob Carpenter

unread,
Oct 10, 2013, 3:18:35 PM10/10/13
to stan...@googlegroups.com
The good news is that I forgot to run with -j4 the first time, so
it's only 5 minutes, not 10 minutes to build. That's
still not good.

The default template depth of 128 in Xcode 5's version
of g++ and clang++ isn't enough.

Here's what gnu says:

-ftemplate-depth=n
Set the maximum instantiation depth for template classes to n. A limit
on the template instantiation depth is needed
to detect endless recursions during template class instantiation.
ANSI/ISO C++ conforming programs must not rely on a
maximum depth greater than 17 (changed to 1024 in C++11).
The default value is 900, as the compiler can run out of
stack space before hitting 1024 in some situations.

http://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html

So we violate pre-C++11 but are OK with C++11.

Xcode for some reason used 128 as the default template-depth. Ours isn't
the only project this broke when building in default settings.

I verified that we can build with:

-ftemplate-depth=256

This works for both g++ and clang++, at least under Xcode 5.

- Bob



Daniel Lee

unread,
Oct 12, 2013, 2:29:26 PM10/12/13
to stan...@googlegroups.com
Bob and/or Jiqiang,

Can you try out this branch and see if it works for XCode 5?
feature/issue-278-Xcode5

The pull request is here:
https://github.com/stan-dev/stan/pull/279

If it works, feel free to merge.




- Bob



--
You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Jiqiang Guo

unread,
Oct 13, 2013, 9:37:49 PM10/13/13
to stan...@googlegroups.com
I am having a problem with this change on a Mac without xcode being updated (I tried to update, but it's still the old version).  So I guess it might be problematic for those who cannot update to Xcode for some reason.   See the following:

$ gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~67/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~67/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
$ make bin/stanc
i686-apple-darwin11-llvm-g++-4.2: src/stan/model/model_header.hpp: linker input file unused because linking not done
g++ -I src -isystem lib/eigen_3.2.0 -isystem lib/boost_1.54.0 -Wall -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -Wno-unused-function -ftemplate-depth=256   -c -O3 -o bin/stan/command/stanc.o src/stan/command/stanc.cpp
cc1plus: error: unrecognized command line option "-ftemplate-depth=256"
make: *** [bin/stan/command/stanc.o] Error 1

The fix for all the g++ I have on mac seems to be using 
-ftemplate-depth-256 instead, which is supported by gcc 4.2.1 on mac (http://goo.gl/qCIjMC). 

--
Jiqiang 

To unsubscribe from this group and stop receiving emails from it, send an email to stan-dev+u...@googlegroups.com.

Bob Carpenter

unread,
Oct 14, 2013, 12:42:41 AM10/14/13
to stan...@googlegroups.com
I'll open an issue for this. We clearly need to test
more thoroughly on versions and probably also on
linux.

On 10/13/13 9:37 PM, Jiqiang Guo wrote:
> I am having a problem with this change on a Mac without xcode being updated (I tried to
> update, but it's still the old version). So I guess it might be problematic for those
> who cannot update to Xcode for some reason. See the following:

Yes, we definitely need to fix this so it works in
at least the last and current versions of Xcode.

> $ make bin/stanc
...
> cc1plus: error: unrecognized command line option "-ftemplate-depth=256"
...
> The fix for all the g++ I have on mac seems to be using
> -ftemplate-depth-256 instead, which is supported by gcc 4.2.1 on mac (http://goo.gl/qCIjMC).

?!? What were they thinking with 4.2.1? I verified that it really
is a "-" and not an "=".

So it looks like we need to do something conditional on the version
of clang++ and g++? Daniel --- is that easy to do in the makefile?

- Bob


Bob Carpenter

unread,
Oct 14, 2013, 12:43:32 AM10/14/13
to stan...@googlegroups.com
Actually, there's already an unclosed issue, which I'll just add to.

https://github.com/stan-dev/stan/issues/278

- Bob

On 10/13/13 9:37 PM, Jiqiang Guo wrote:
> On Sat, Oct 12, 2013 at 2:29 PM, Daniel Lee <bea...@alum.mit.edu <mailto:bea...@alum.mit.edu>> wrote:
>
> Bob and/or Jiqiang,
>
> Can you try out this branch and see if it works for XCode 5?
> feature/issue-278-Xcode5
>
> The pull request is here:
> https://github.com/stan-dev/stan/pull/279
>
> If it works, feel free to merge.
>
>
> On Thu, Oct 10, 2013 at 3:18 PM, Bob Carpenter <ca...@alias-i.com <mailto:ca...@alias-i.com>> wrote:
>
> The good news is that I forgot to run with -j4 the first time, so
> it's only 5 minutes, not 10 minutes to build. That's
> still not good.
>
> The default template depth of 128 in Xcode 5's version
> of g++ and clang++ isn't enough.
>
> Here's what gnu says:
>
> -ftemplate-depth=n
> Set the maximum instantiation depth for template classes to n. A limit
> on the template instantiation depth is needed
> to detect endless recursions during template class instantiation.
> ANSI/ISO C++ conforming programs must not rely on a
> maximum depth greater than 17 (changed to 1024 in C++11).
> The default value is 900, as the compiler can run out of
> stack space before hitting 1024 in some situations.
>
> http://gcc.gnu.org/onlinedocs/__gcc/C_002b_002b-Dialect-__Options.html
> <http://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html>
>
> So we violate pre-C++11 but are OK with C++11.
>
> Xcode for some reason used 128 as the default template-depth. Ours isn't
> the only project this broke when building in default settings.
>
> I verified that we can build with:
>
> -ftemplate-depth=256
>
> This works for both g++ and clang++, at least under Xcode 5.
>
> - Bob
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> stan-dev+unsubscribe@__googlegroups.com <mailto:stan-dev%2Bunsu...@googlegroups.com>.
> For more options, visit https://groups.google.com/__groups/opt_out <https://groups.google.com/groups/opt_out>.
>
>
> --
> You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> stan-dev+u...@googlegroups.com <mailto:stan-dev%2Bunsu...@googlegroups.com>.
Reply all
Reply to author
Forward
0 new messages