swar-mukh / cbt

cbt is a postmodern build tool aimed to provide a standard application structure and facilitate code re-use, thereby making working with C++ a breeze.
GNU Affero General Public License v3.0
4 stars 0 forks source link

Unable to compile on MacOS #10

Closed swar-mukh closed 3 days ago

swar-mukh commented 4 days ago

Describe the bug

When ./script.sh init compile build is invoked, cbt fails to compile with the following error:


# Additional output omitted

==============
Phase: compile
==============

[COMPILE] src/Workspace/env_manager.cpp
clang: warning: argument unused during compilation: '-s' [-Wunused-command-line-argument]
[COMPILE] src/workspace/modification_identifier.cpp
clang: warning: argument unused during compilation: '-s' [-Wunused-command-line-argument]
src/workspace/modification_identifier.cpp:33:52: error: call to deleted constructor of '_enum_hash<path>'
        return std::make_tuple(std::hash<fs::path>{}(normalised_file_name), normalised_path);
                                                  ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/hash.h:643
        __enum_hash() = delete;
        ^
src/workspace/modification_identifier.cpp:33:32: error: type 'std::hash<fs::path>' does not provide a call operator
        return std::make_tuple(std::hash<fs::path>(normalised_file_name), normalised_path);
                               ^~~~~~~~~~~~~~~~~~~

# Additional output omitted

cbt information

Environment

clang -v # Update this if necessary Apple clang version 15.0.0 (clang-1500.3.9.4) Target: arm64-apple-darwin23.2.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin

To reproduce

Steps to reproduce the behaviour:

  1. Clone the repo
  2. Run ./script.sh init compile build

Expected behaviour (optional)

Build should be successful

Additional context (optional)

Thanks @ratnadeep007 for pointing it out!

swar-mukh commented 4 days ago

As per the documentation for std::hash<std::filesystem::path> in C++ reference, the operator() is not enabled for C++17 and below.

This specialization was absent from the C++17 standard publication, see LWG issue 3657.

I guess the clang C++ compiler (w.r.t. this bug report) is also missing the above in its implementation. The only option currently is to downgrade the usage at call site to std::filesystem::hash_value(p).