recompiling main.cpp each time

未关闭
#1,094 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
cpp
领域
build-system, cli

调研方向

从构建 src/cmdstan/main.o 的 make 规则开始,追踪模型转换失败后该规则为何会再次运行。使用 make ~/temp2/abs 重现这一过程,包括一个失败的 Stan 模型,随后使用一个已修正的模型。完成的标准是:在 main.cpp 及其依赖项未发生变化时,后续的 make 会复用 main.o;而在它们发生变化时重新构建 main.o。

由索引模型根据 Issue 内容生成。

描述

bug makefile
Summary:

When I run the latest develop version of cmdstan, it recompiles the main.cpp every time, but it should only have to be compiled once.

Description:

The main.cpp should only be compiled once, then re-used.

Reproducible Steps & Current Output
Run 1
~/github/stan-dev/cmdstan (develop)$ make ~/temp2/abs
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS          -c -MT stan/src/stan/model/model_header.hpp.gch -MT stan/src/stan/model/model_header.d -MM -E -MG -MP -MF stan/src/stan/model/model_header.d stan/src/stan/model/model_header.hpp

--- Compiling the main object file. This might take up to a minute. ---
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS          -c -o src/cmdstan/main.o src/cmdstan/main.cpp

--- Compiling pre-compiled header. This might take a few seconds. ---
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS          -c stan/src/stan/model/model_header.hpp -o stan/src/stan/model/model_header.hpp.gch

--- Translating Stan model to C++ code ---
bin/stanc  --o=/Users/bcarpenter/temp2/abs.hpp /Users/bcarpenter/temp2/abs.stan
Semantic error in '/Users/bcarpenter/temp2/abs.stan', line 4, column 20 to column 35:
   -------------------------------------------------
     2:    int a = abs(2);
     3:    real b = abs(2.9);
     4:    array[2] real c = abs({1.9, 2.8});
                             ^
     5:    array[2] int d = abs({1, 2});
     6:    vector[2] e = abs([1.2, 3.9]');
   -------------------------------------------------

Ill-typed arguments supplied to function 'abs':
(array[] real)
Available signatures:
(int) => int
  The first argument must be int but got array[] real
(real) => real
  The first argument must be real but got array[] realmake: *** [/Users/bcarpenter/temp2/abs.hpp] Error 1

So this fails to compile the model, but what happens to the make.cpp compilation?

Run 2

It just happens again. And remember "This might take up to a minute."

~/github/stan-dev/cmdstan (develop)$ make ~/temp2/abs

--- Compiling the main object file. This might take up to a minute. ---
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS          -c -o src/cmdstan/main.o src/cmdstan/main.cpp

--- Translating Stan model to C++ code ---
bin/stanc  --o=/Users/bcarpenter/temp2/abs.hpp /Users/bcarpenter/temp2/abs.stan
Semantic error in '/Users/bcarpenter/temp2/abs.stan', line 5, column 2 to column 32:
   -------------------------------------------------
     3:    real b = abs(2.9);
     4:    array[2] real c = fabs({1.9, 2.8});
     5:    array[2] int d = fabs({1, 2});
           ^
     6:    vector[2] e = fabs([1.2, 3.9]');
     7:    row_vector[2] f = fabs([1.2, 3.9]);
   -------------------------------------------------

Ill-typed arguments supplied to assignment operator =: lhs has type array[] int and rhs has type array[] realmake: *** [/Users/bcarpenter/temp2/abs.hpp] Error 1
Run 3

Here we go again.

~/github/stan-dev/cmdstan (develop)$ make ~/temp2/abs

--- Compiling the main object file. This might take up to a minute. ---
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS          -c -o src/cmdstan/main.o src/cmdstan/main.cpp

--- Translating Stan model to C++ code ---
bin/stanc  --o=/Users/bcarpenter/temp2/abs.hpp /Users/bcarpenter/temp2/abs.stan
Syntax error in '/Users/bcarpenter/temp2/abs.stan', line 5, column 11 to column 17, parsing error:
   -------------------------------------------------
     3:    real b = abs(2.9);
     4:    array[2] real c = fabs({1.9, 2.8});
     5:    array[2] double d = fabs({1, 2});
                    ^
     6:    vector[2] e = fabs([1.2, 3.9]');
     7:    row_vector[2] f = fabs([1.2, 3.9]);
   -------------------------------------------------

Ill-formed phrase. Found L-value. This can be completed in many ways.
make: *** [/Users/bcarpenter/temp2/abs.hpp] Error 1
Run 4

One more time, with feeling.

~/github/stan-dev/cmdstan (develop)$ make ~/temp2/abs

--- Compiling the main object file. This might take up to a minute. ---
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS          -c -o src/cmdstan/main.o src/cmdstan/main.cpp

--- Translating Stan model to C++ code ---
bin/stanc  --o=/Users/bcarpenter/temp2/abs.hpp /Users/bcarpenter/temp2/abs.stan
Warning in '/Users/bcarpenter/temp2/abs.stan', line 3, column 11: Use of the `abs` function with real-valued arguments is deprecated; use functions `fabs` instead.
--- Compiling, linking C++ code ---
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS          -c -include-pch stan/src/stan/model/model_header.hpp.gch -x c++ -o /Users/bcarpenter/temp2/abs.o /Users/bcarpenter/temp2/abs.hpp
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS                -Wl,-L,"/Users/bcarpenter/github/stan-dev/cmdstan/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"/Users/bcarpenter/github/stan-dev/cmdstan/stan/lib/stan_math/lib/tbb"      /Users/bcarpenter/temp2/abs.o src/cmdstan/main.o        -Wl,-L,"/Users/bcarpenter/github/stan-dev/cmdstan/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"/Users/bcarpenter/github/stan-dev/cmdstan/stan/lib/stan_math/lib/tbb"   stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_nvecserial.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_cvodes.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_idas.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_kinsol.a  stan/lib/stan_math/lib/tbb/libtbb.dylib stan/lib/stan_math/lib/tbb/libtbbmalloc.dylib stan/lib/stan_math/lib/tbb/libtbbmalloc_proxy.dylib -o /Users/bcarpenter/temp2/abs
rm -f /Users/bcarpenter/temp2/abs.o
~/github/stan-dev/cmdstan (develop)$ make ~/temp2/abs

--- Translating Stan model to C++ code ---
bin/stanc  --o=/Users/bcarpenter/temp2/abs.hpp /Users/bcarpenter/temp2/abs.stan
Warning in '/Users/bcarpenter/temp2/abs.stan', line 3, column 11: Use of the `abs` function with real-valued arguments is deprecated; use functions `fabs` instead.
--- Compiling the main object file. This might take up to a minute. ---
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS          -c -o src/cmdstan/main.o src/cmdstan/main.cpp

--- Compiling, linking C++ code ---
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS          -c -include-pch stan/src/stan/model/model_header.hpp.gch -x c++ -o /Users/bcarpenter/temp2/abs.o /Users/bcarpenter/temp2/abs.hpp
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS                -Wl,-L,"/Users/bcarpenter/github/stan-dev/cmdstan/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"/Users/bcarpenter/github/stan-dev/cmdstan/stan/lib/stan_math/lib/tbb"      /Users/bcarpenter/temp2/abs.o src/cmdstan/main.o        -Wl,-L,"/Users/bcarpenter/github/stan-dev/cmdstan/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"/Users/bcarpenter/github/stan-dev/cmdstan/stan/lib/stan_math/lib/tbb"   stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_nvecserial.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_cvodes.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_idas.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_kinsol.a  stan/lib/stan_math/lib/tbb/libtbb.dylib stan/lib/stan_math/lib/tbb/libtbbmalloc.dylib stan/lib/stan_math/lib/tbb/libtbbmalloc_proxy.dylib -o /Users/bcarpenter/temp2/abs
rm -f /Users/bcarpenter/temp2/abs.o
Run 5

OK, this time it succeeded. Now let me change my program for abs and see what happens.

It still recompiles main.cpp.

~/github/stan-dev/cmdstan (develop)$ make ~/temp2/abs

--- Translating Stan model to C++ code ---
bin/stanc  --o=/Users/bcarpenter/temp2/abs.hpp /Users/bcarpenter/temp2/abs.stan
Warning in '/Users/bcarpenter/temp2/abs.stan', line 3, column 11: Use of the `abs` function with real-valued arguments is deprecated; use functions `fabs` instead.
--- Compiling the main object file. This might take up to a minute. ---
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS          -c -o src/cmdstan/main.o src/cmdstan/main.cpp

--- Compiling, linking C++ code ---
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS          -c -include-pch stan/src/stan/model/model_header.hpp.gch -x c++ -o /Users/bcarpenter/temp2/abs.o /Users/bcarpenter/temp2/abs.hpp
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS                -Wl,-L,"/Users/bcarpenter/github/stan-dev/cmdstan/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"/Users/bcarpenter/github/stan-dev/cmdstan/stan/lib/stan_math/lib/tbb"      /Users/bcarpenter/temp2/abs.o src/cmdstan/main.o        -Wl,-L,"/Users/bcarpenter/github/stan-dev/cmdstan/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"/Users/bcarpenter/github/stan-dev/cmdstan/stan/lib/stan_math/lib/tbb"   stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_nvecserial.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_cvodes.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_idas.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_kinsol.a  stan/lib/stan_math/lib/tbb/libtbb.dylib stan/lib/stan_math/lib/tbb/libtbbmalloc.dylib stan/lib/stan_math/lib/tbb/libtbbmalloc_proxy.dylib -o /Users/bcarpenter/temp2/abs
rm -f /Users/bcarpenter/temp2/abs.o
Expected Output:

Only see recompilation of main.cpp once.

Additional Information:

This is on Mac OS X.

~/github/stan-dev/cmdstan (develop)$ clang++ --version
Apple clang version 13.1.6 (clang-1316.0.21.2.3)
Target: x86_64-apple-darwin21.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
~/github/stan-dev/cmdstan (develop)$ make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
Current Version:

v2.29.2

主要语言
C++
星标
240
派生
105
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

stan-dev/cmdstan 的其他 Issue

查看 stan-dev/cmdstan 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。