Commit b49ef38c authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

Comment out a debug logging for extern subroutine handler



Also, hook the `-qs-build-exe` option to control if we need to build with `<OutputType>Exe</OutputType>` or not.

In order to use the official release, we need that option.

Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent 838c74e2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ function(add_qcor_qsharp_test test_name relative_qs_source_location relative_cpp
  NAME
    ${test_name}
  COMMAND
    bash -c "${CMAKE_BINARY_DIR}/qcor -qrt ftqc ${CMAKE_CURRENT_SOURCE_DIR}/${relative_qs_source_location} ${CMAKE_CURRENT_SOURCE_DIR}/${relative_cpp_source_location} -o ${test_name}; \
    bash -c "${CMAKE_BINARY_DIR}/qcor -qrt ftqc -qs-build-exe ${CMAKE_CURRENT_SOURCE_DIR}/${relative_qs_source_location} ${CMAKE_CURRENT_SOURCE_DIR}/${relative_cpp_source_location} -o ${test_name}; \
              ${CMAKE_CURRENT_BINARY_DIR}/${test_name}"
  )
endfunction()
+1 −1
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ antlrcpp::Any qasm3_visitor::visitSubroutineDefinition(
  }
  // Handle "extern" subroutine declaration:
  if (context->subroutineBlock()->EXTERN()) {
    std::cout << "Handle extern subroutine: " << subroutine_name << "\n";
    // std::cout << "Handle extern subroutine: " << subroutine_name << "\n";
    builder.setInsertionPointToStart(&m_module.getRegion().getBlocks().front());
    builder.create<mlir::FuncOp>(get_location(builder, file_name, context),
                                 subroutine_name,
+16 −8
Original line number Diff line number Diff line
@@ -4,10 +4,14 @@ import argparse, sys, os, glob, subprocess, mimetypes, re, pathlib
# Helper to generate Q# build config by running the SDK
# Input: the source file directory where the build
# csproj will be saved to.
def generate_qsc_build_command(target_name, src_dir, input_files, qdk_ver):
def generate_qsc_build_command(target_name, src_dir, input_files, qdk_ver, build_exe):
  import os, tempfile, shutil
  temp_dir = tempfile.mkdtemp()
  # print(temp_dir)
  # Build console/classlib depending on build_exe flag
  if (build_exe):
    os.system('dotnet new console -lang Q# -o ' + temp_dir + ' -n test')
  else:
    os.system('dotnet new classlib -lang Q# -o ' + temp_dir + ' -n test')

  import xml.etree.ElementTree as ET
@@ -447,8 +451,17 @@ def main(argv=None):
            sys.argv.remove(qdk_version)
            sys.argv.remove('-qdk-version')

        # Should we handle entry-point operations
        # and generate Interop entry point QIR.
        # Note: This is mainly to handle the transition period with alpha-release of Q# SDK.
        # (the official release will complain if we don't build exe)
        qs_build_exe = False
        if '-qs-build-exe' in sys.argv[1:]:
            sys.argv.remove('-qs-build-exe')
            qs_build_exe = True

        # Generate build command:
        build_cmd = generate_qsc_build_command(base_name, os.path.dirname(os.path.abspath(filename)), [filename], qdk_version)
        build_cmd = generate_qsc_build_command(base_name, os.path.dirname(os.path.abspath(filename)), [filename], qdk_version, qs_build_exe)
        # QSharp compiler now generates a bitcode file,
        # i.e. no need to do llvm-as
        bc_file_name = base_name + '.bc'
@@ -470,11 +483,6 @@ def main(argv=None):
            sys.argv.remove(qs_rt_name)
            sys.argv.remove('-qs-runtime')

        qs_build_exe = ''
        if '-qs-build-exe' in sys.argv[1:]:
            sys.argv.remove('-qs-build-exe')
            qs_build_exe = '--build-exe'

        # Execute qsc build command:
        os.system(build_cmd)
        llvm_bin_path = str(pathlib.Path(compiler).parent)