AmrDeveloper / Amun

A Statically typed, compiled general purpose low level programming language built using C++ and LLVM Infrastructure framework designed to be simple and fast
https://amun-lang.github.io/docs/
MIT License
62 stars 3 forks source link

Can't build (macOS) #4

Open genericptr opened 10 months ago

genericptr commented 10 months ago

Is my C++ compiler the wrong version maybe?

build$ cmake ..
-- The C compiler identification is AppleClang 14.0.0.14000029
-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test HAVE_FFI_CALL
-- Performing Test HAVE_FFI_CALL - Success
-- Found FFI: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/lib/libffi.tbd  
-- Performing Test Terminfo_LINKABLE
-- Performing Test Terminfo_LINKABLE - Success
-- Found Terminfo: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/lib/libcurses.tbd  
-- Found ZLIB: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/lib/libz.tbd (found version "1.2.11")  
-- Found zstd: /opt/homebrew/lib/libzstd.dylib  
-- Found LibXml2: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/lib/libxml2.tbd (found version "2.9.4") 
-- Found LLVM 16.0.4
-- Using LLVMConfig.cmake in: /opt/homebrew/opt/llvm@16/lib/cmake/llvm
-- Configuring done (4.5s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/ryanjoseph/Downloads/Amun-master/build
build$ make
[  5%] Building CXX object CMakeFiles/amun.dir/src/amun_alias_table.cpp.o
[ 10%] Building CXX object CMakeFiles/amun.dir/src/amun_basic.cpp.o
[ 15%] Building CXX object CMakeFiles/amun.dir/src/amun_command.cpp.o
[ 21%] Building CXX object CMakeFiles/amun.dir/src/amun_compiler.cpp.o
In file included from /Users/ryanjoseph/Downloads/Amun-master/src/amun_compiler.cpp:4:
In file included from /Users/ryanjoseph/Downloads/Amun-master/src/../include/amun_llvm_backend.hpp:6:
/Users/ryanjoseph/Downloads/Amun-master/include/amun_llvm_builder.hpp:57:53: warning: 'getPointerElementType' is deprecated: Deprecated without replacement, see https://llvm.org/docs/OpaquePointers.html for context and migration instructions [-Wdeprecated-declarations]
    auto pointer_element_type = pointer->getType()->getPointerElementType();
                                                    ^
/opt/homebrew/opt/llvm@16/include/llvm/IR/Type.h:406:5: note: 'getPointerElementType' has been explicitly marked deprecated here
  [[deprecated("Deprecated without replacement, see "
    ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_compiler.cpp:94:15: error: no template named 'Optional' in namespace 'llvm'; did you mean 'std::optional'?
    auto rm = llvm::Optional<llvm::Reloc::Model>();
              ^~~~~~~~~~~~~~
              std::optional
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/c++/v1/optional:590:7: note: 'std::optional' declared here
class optional
      ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_compiler.cpp:173:15: error: no template named 'Optional' in namespace 'llvm'; did you mean 'std::optional'?
    auto rm = llvm::Optional<llvm::Reloc::Model>();
              ^~~~~~~~~~~~~~
              std::optional
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/c++/v1/optional:590:7: note: 'std::optional' declared here
class optional
      ^
1 warning and 2 errors generated.
make[2]: *** [CMakeFiles/amun.dir/src/amun_compiler.cpp.o] Error 1
make[1]: *** [CMakeFiles/amun.dir/all] Error 2
make: *** [all] Error 2
build$ 
AmrDeveloper commented 10 months ago

Hello @genericptr,

I think you need to use updated clang version to be able to compile C++20

genericptr commented 10 months ago

I don't use C++ much on macOS but I think you may need to add some additional flags to get c++ 20 support. It's also possible Apple hasn't implemented the full feature set.

There's the version I'm using which seems to be up to date.

Homebrew clang version 16.0.4
Target: arm64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm@16/bin
AmrDeveloper commented 10 months ago

I will search about this issue and check if i can solved it by adding flag or other thing

AmrDeveloper commented 10 months ago

@genericptr Can you please add this line on amun_compiler.cpp file

#include <llvm/ADT/Optional.h>
genericptr commented 10 months ago

great that fixed that error. I still get errors but these are probably because I'm using LLVM 16. I think I can download a LLVM 15 version but not sure if the build system will use the correct one.

build$ make
[  5%] Building CXX object CMakeFiles/amun.dir/src/amun_compiler.cpp.o
In file included from /Users/ryanjoseph/Downloads/Amun-master/src/amun_compiler.cpp:4:
In file included from /Users/ryanjoseph/Downloads/Amun-master/src/../include/amun_llvm_backend.hpp:6:
/Users/ryanjoseph/Downloads/Amun-master/include/amun_llvm_builder.hpp:57:53: warning: 'getPointerElementType' is deprecated: Deprecated without replacement, see https://llvm.org/docs/OpaquePointers.html for context and migration instructions [-Wdeprecated-declarations]
    auto pointer_element_type = pointer->getType()->getPointerElementType();
                                                    ^
/opt/homebrew/opt/llvm@16/include/llvm/IR/Type.h:406:5: note: 'getPointerElementType' has been explicitly marked deprecated here
  [[deprecated("Deprecated without replacement, see "
    ^
1 warning generated.
[ 10%] Building CXX object CMakeFiles/amun.dir/src/amun_compiler_options.cpp.o
[ 15%] Building CXX object CMakeFiles/amun.dir/src/amun_diagnostics.cpp.o
[ 21%] Building CXX object CMakeFiles/amun.dir/src/amun_external_linker.cpp.o
[ 26%] Building CXX object CMakeFiles/amun.dir/src/amun_files.cpp.o
[ 31%] Building CXX object CMakeFiles/amun.dir/src/amun_llvm_backend.cpp.o
In file included from /Users/ryanjoseph/Downloads/Amun-master/src/amun_llvm_backend.cpp:1:
In file included from /Users/ryanjoseph/Downloads/Amun-master/src/../include/amun_llvm_backend.hpp:6:
/Users/ryanjoseph/Downloads/Amun-master/include/amun_llvm_builder.hpp:57:53: warning: 'getPointerElementType' is deprecated: Deprecated without replacement, see https://llvm.org/docs/OpaquePointers.html for context and migration instructions [-Wdeprecated-declarations]
    auto pointer_element_type = pointer->getType()->getPointerElementType();
                                                    ^
/opt/homebrew/opt/llvm@16/include/llvm/IR/Type.h:406:5: note: 'getPointerElementType' has been explicitly marked deprecated here
  [[deprecated("Deprecated without replacement, see "
    ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_llvm_backend.cpp:129:62: warning: 'getPointerElementType' is deprecated: Deprecated without replacement, see https://llvm.org/docs/OpaquePointers.html for context and migration instructions [-Wdeprecated-declarations]
        if (init_value_type != llvm_type && init_value_type->getPointerElementType() == llvm_type) {
                                                             ^
/opt/homebrew/opt/llvm@16/include/llvm/IR/Type.h:406:5: note: 'getPointerElementType' has been explicitly marked deprecated here
  [[deprecated("Deprecated without replacement, see "
    ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_llvm_backend.cpp:467:23: error: 'getBasicBlockList' is a private member of 'llvm::Function'
    current_function->getBasicBlockList().push_back(start_block);
    ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/homebrew/opt/llvm@16/include/llvm/IR/Function.h:728:29: note: declared private here
        BasicBlockListType &getBasicBlockList()       { return BasicBlocks; }
                            ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_llvm_backend.cpp:474:27: error: 'getBasicBlockList' is a private member of 'llvm::Function'
        current_function->getBasicBlockList().push_back(true_block);
        ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/homebrew/opt/llvm@16/include/llvm/IR/Function.h:728:29: note: declared private here
        BasicBlockListType &getBasicBlockList()       { return BasicBlocks; }
                            ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_llvm_backend.cpp:479:31: error: 'getBasicBlockList' is a private member of 'llvm::Function'
            current_function->getBasicBlockList().push_back(false_branch);
            ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/homebrew/opt/llvm@16/include/llvm/IR/Function.h:728:29: note: declared private here
        BasicBlockListType &getBasicBlockList()       { return BasicBlocks; }
                            ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_llvm_backend.cpp:499:23: error: 'getBasicBlockList' is a private member of 'llvm::Function'
    current_function->getBasicBlockList().push_back(end_block);
    ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/homebrew/opt/llvm@16/include/llvm/IR/Function.h:728:29: note: declared private here
        BasicBlockListType &getBasicBlockList()       { return BasicBlocks; }
                            ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_llvm_backend.cpp:549:23: error: 'getBasicBlockList' is a private member of 'llvm::Function'
    current_function->getBasicBlockList().push_back(condition_block);
    ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/homebrew/opt/llvm@16/include/llvm/IR/Function.h:728:29: note: declared private here
        BasicBlockListType &getBasicBlockList()       { return BasicBlocks; }
                            ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_llvm_backend.cpp:556:23: error: 'getBasicBlockList' is a private member of 'llvm::Function'
    current_function->getBasicBlockList().push_back(body_block);
    ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/homebrew/opt/llvm@16/include/llvm/IR/Function.h:728:29: note: declared private here
        BasicBlockListType &getBasicBlockList()       { return BasicBlocks; }
                            ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_llvm_backend.cpp:575:23: error: 'getBasicBlockList' is a private member of 'llvm::Function'
    current_function->getBasicBlockList().push_back(end_block);
    ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/homebrew/opt/llvm@16/include/llvm/IR/Function.h:728:29: note: declared private here
        BasicBlockListType &getBasicBlockList()       { return BasicBlocks; }
                            ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_llvm_backend.cpp:635:23: error: 'getBasicBlockList' is a private member of 'llvm::Function'
    current_function->getBasicBlockList().push_back(condition_block);
    ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/homebrew/opt/llvm@16/include/llvm/IR/Function.h:728:29: note: declared private here
        BasicBlockListType &getBasicBlockList()       { return BasicBlocks; }
                            ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_llvm_backend.cpp:642:23: error: 'getBasicBlockList' is a private member of 'llvm::Function'
    current_function->getBasicBlockList().push_back(body_block);
    ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/homebrew/opt/llvm@16/include/llvm/IR/Function.h:728:29: note: declared private here
        BasicBlockListType &getBasicBlockList()       { return BasicBlocks; }
                            ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_llvm_backend.cpp:682:23: error: 'getBasicBlockList' is a private member of 'llvm::Function'
    current_function->getBasicBlockList().push_back(end_block);
    ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/homebrew/opt/llvm@16/include/llvm/IR/Function.h:728:29: note: declared private here
        BasicBlockListType &getBasicBlockList()       { return BasicBlocks; }
                            ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_llvm_backend.cpp:706:23: error: 'getBasicBlockList' is a private member of 'llvm::Function'
    current_function->getBasicBlockList().push_back(body_block);
    ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/homebrew/opt/llvm@16/include/llvm/IR/Function.h:728:29: note: declared private here
        BasicBlockListType &getBasicBlockList()       { return BasicBlocks; }
                            ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_llvm_backend.cpp:719:23: error: 'getBasicBlockList' is a private member of 'llvm::Function'
    current_function->getBasicBlockList().push_back(end_block);
    ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/homebrew/opt/llvm@16/include/llvm/IR/Function.h:728:29: note: declared private here
        BasicBlockListType &getBasicBlockList()       { return BasicBlocks; }
                            ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_llvm_backend.cpp:739:23: error: 'getBasicBlockList' is a private member of 'llvm::Function'
    current_function->getBasicBlockList().push_back(condition_branch);
    ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/homebrew/opt/llvm@16/include/llvm/IR/Function.h:728:29: note: declared private here
        BasicBlockListType &getBasicBlockList()       { return BasicBlocks; }
                            ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_llvm_backend.cpp:745:23: error: 'getBasicBlockList' is a private member of 'llvm::Function'
    current_function->getBasicBlockList().push_back(loop_branch);
    ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/homebrew/opt/llvm@16/include/llvm/IR/Function.h:728:29: note: declared private here
        BasicBlockListType &getBasicBlockList()       { return BasicBlocks; }
                            ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_llvm_backend.cpp:759:23: error: 'getBasicBlockList' is a private member of 'llvm::Function'
    current_function->getBasicBlockList().push_back(end_branch);
    ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/homebrew/opt/llvm@16/include/llvm/IR/Function.h:728:29: note: declared private here
        BasicBlockListType &getBasicBlockList()       { return BasicBlocks; }
                            ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_llvm_backend.cpp:990:15: error: 'getBasicBlockList' is a private member of 'llvm::Function'
    function->getBasicBlockList().push_back(elseBB);
    ~~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/homebrew/opt/llvm@16/include/llvm/IR/Function.h:728:29: note: declared private here
        BasicBlockListType &getBasicBlockList()       { return BasicBlocks; }
                            ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_llvm_backend.cpp:998:15: error: 'getBasicBlockList' is a private member of 'llvm::Function'
    function->getBasicBlockList().push_back(mergeBB);
    ~~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/homebrew/opt/llvm@16/include/llvm/IR/Function.h:728:29: note: declared private here
        BasicBlockListType &getBasicBlockList()       { return BasicBlocks; }
                            ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_llvm_backend.cpp:1063:15: error: 'getBasicBlockList' is a private member of 'llvm::Function'
    function->getBasicBlockList().push_back(first_branch);
    ~~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/homebrew/opt/llvm@16/include/llvm/IR/Function.h:728:29: note: declared private here
        BasicBlockListType &getBasicBlockList()       { return BasicBlocks; }
                            ^
/Users/ryanjoseph/Downloads/Amun-master/src/amun_llvm_backend.cpp:1078:19: error: 'getBasicBlockList' is a private member of 'llvm::Function'
        function->getBasicBlockList().push_back(current_branch);
        ~~~~~~~~~~^~~~~~~~~~~~~~~~~
/opt/homebrew/opt/llvm@16/include/llvm/IR/Function.h:728:29: note: declared private here
        BasicBlockListType &getBasicBlockList()       { return BasicBlocks; }
                            ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 warnings and 20 errors generated.
make[2]: *** [CMakeFiles/amun.dir/src/amun_llvm_backend.cpp.o] Error 1
make[1]: *** [CMakeFiles/amun.dir/all] Error 2
make: *** [all] Error 2
build$ 
AmrDeveloper commented 10 months ago

@genericptr Great, Yes i think getPointerElementType removed from llvm 16, it will work fine on llvm 15 and i will asap modify the code to work fine on llvm 16 and above