Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows build crashes on Abaci library exception #1

Open
cpp-tutor opened this issue Jun 22, 2024 · 0 comments
Open

Windows build crashes on Abaci library exception #1

cpp-tutor opened this issue Jun 22, 2024 · 0 comments

Comments

@cpp-tutor
Copy link
Owner

cpp-tutor commented Jun 22, 2024

The LLVM-generated code uses a library (lib/Abaci.cpp) to provide functionality, such as I/O, complex number calculations and type conversions. This library can throw exceptions, which are not appearing to be successfully caught by the driver under the Windows build. Things I have tried to make a working Windows build:

  • Compile project, fmt and LLVM libraries with -DCMAKE_BUILD_TYPE=Release
  • Compile project with flags /EHsc
  • Remove extern "C" { from lib/Abaci.cpp
  • Compile LLVM with -D-DLLVM_ENABLE_EH=ON -DLLVM_ENABLE_RTTI=ON which appears to set some sub-projects to use /EHsc
  • Attempt to remove nounwind attribute from generated functions: current_function->addFnAttr(Attribute::UWTable);
  • Add the following code to engine/JIT.cpp:
    auto JTMB = JITTargetMachineBuilder::detectHost();
    if (!JTMB) {
        errs() << "Error detecting host: " << toString(JTMB.takeError()) << "\n";
    }
    auto opts = JTMB->getOptions();
    opts.ExceptionModel = ExceptionHandling::WinEH; // Enable exception handling
    JTMB->setOptions(opts);

    jit = jit_builder.setJITTargetMachineBuilder(std::move(*JTMB)).create();

I'm guessing that all of these steps, plus other(s), are necessary, however I lack detailed knowledge of LLVM and the Windows build system. Any assistance to correct this issue would be greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant