Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

Commit

Permalink
Fix compilation on macOS (#68)
Browse files Browse the repository at this point in the history
* Make macOS CI script pick the right Clang version

* Fix 'implicit instantiation of undefined template' error

Here is the error:

```
/Users/anton/zilliqa/scilla-rtl/testsuite/ContrTests.cpp:147:23: error: implicit instantiation of undefined template 'std::basic_ofstream<char>'
        std::ofstream Out(PathPrefix + Input.ExpectedStateFilename);
                      ^
/usr/local/opt/llvm@13/bin/../include/c++/v1/iosfwd:149:32: note: template is declared here
    class _LIBCPP_TEMPLATE_VIS basic_ofstream;
                               ^
/Users/anton/zilliqa/scilla-rtl/testsuite/ContrTests.cpp:162:23: error: implicit instantiation of undefined template 'std::basic_ofstream<char>'
        std::ofstream Out(PathPrefix + Input.ExpectedOutputFilename);
                      ^
/usr/local/opt/llvm@13/bin/../include/c++/v1/iosfwd:149:32: note: template is declared here
    class _LIBCPP_TEMPLATE_VIS basic_ofstream;
                               ^
2 errors generated.
make[3]: *** [testsuite/CMakeFiles/scilla-testsuite.dir/ContrTests.cpp.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [testsuite/CMakeFiles/scilla-testsuite.dir/all] Error 2
make[1]: *** [testsuite/CMakeFiles/runtests.dir/rule] Error 2
make: *** [runtests] Error 2
```
  • Loading branch information
Anton Trunov authored Jul 7, 2022
1 parent 8403ccf commit bf0c893
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
9 changes: 8 additions & 1 deletion scripts/build_ci_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,12 @@
echo "Building release build with address sanitizer"
export PATH=/usr/local/opt/llvm@13/bin:$PATH
export LIBRARY_PATH=/usr/local/opt/jsoncpp/lib:/usr/local/opt/secp256k1/lib/
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DADDRESS_SANITIZER=1

# CMAKE_C_COMPILER and CMAKE_CXX_COMPILER make cmake pick the Homebrew Clang installation
# and not the default AppleClang compiler
# See https://github.com/taichi-dev/taichi/issues/3578 and some links there:
# - https://github.com/taichi-dev/taichi/pull/3379
# - https://stackoverflow.com/questions/45933732/how-to-specify-a-compiler-in-cmake
cmake -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++ -B build -S . -DCMAKE_BUILD_TYPE=Release -DADDRESS_SANITIZER=1

cmake --build build --target runtests -j4
9 changes: 8 additions & 1 deletion scripts/dbuild_ci_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,12 @@
echo "Building debug build with address sanitizer"
export PATH=/usr/local/opt/llvm@13/bin:$PATH
export LIBRARY_PATH=/usr/local/opt/jsoncpp/lib:/usr/local/opt/secp256k1/lib/
cmake -B build -S . -DCMAKE_BUILD_TYPE=Debug -DADDRESS_SANITIZER=1

# CMAKE_C_COMPILER and CMAKE_CXX_COMPILER make cmake pick the Homebrew Clang installation
# and not the default AppleClang compiler
# See https://github.com/taichi-dev/taichi/issues/3578 and some links there:
# - https://github.com/taichi-dev/taichi/pull/3379
# - https://stackoverflow.com/questions/45933732/how-to-specify-a-compiler-in-cmake
cmake -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++ -B build -S . -DCMAKE_BUILD_TYPE=Debug -DADDRESS_SANITIZER=1

cmake --build build --target runtests -j4
1 change: 1 addition & 0 deletions testsuite/ContrTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <fstream>
#include <boost/filesystem.hpp>
#include <boost/test/tools/output_test_stream.hpp>
#include <boost/test/unit_test.hpp>
Expand Down

0 comments on commit bf0c893

Please sign in to comment.