recompiling main.cpp each time

オープン
#1,094 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp
領域
build-system, cli

調査の方向性

src/cmdstan/main.oをビルドするmakeルールから始め、モデルの変換に失敗した後にそれが再度実行される理由を追跡します。失敗するStanモデルに続けて修正済みのモデルを使い、make ~/temp2/absでその一連の流れを再現します。main.cppとその依存関係が変更されていない場合に、後続のmakeが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. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

stan-dev/cmdstan のほかの issue

stan-dev/cmdstan の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。