diff --git a/.github/workflows/root-ci-config/build_root.py b/.github/workflows/root-ci-config/build_root.py index bdab8ab2bd254..2a25dae37914b 100755 --- a/.github/workflows/root-ci-config/build_root.py +++ b/.github/workflows/root-ci-config/build_root.py @@ -77,7 +77,8 @@ def main(): # file below overwrites values from above **load_config(f'{this_script_dir}/buildconfig/{args.platform}.txt') } - + if WINDOWS and pull_request: + options_dict["clingtest"] = 'on' if args.clingtest else 'off' options = build_utils.cmake_options_from_dict(options_dict) if WINDOWS: @@ -197,6 +198,7 @@ def parse_args(): parser.add_argument("--dockeropts", default=None, help="Extra docker options, if any") parser.add_argument("--incremental", default="false", help="Do incremental build") parser.add_argument("--buildtype", default="Release", help="Release|Debug|RelWithDebInfo") + parser.add_argument("--clingtest", default="false", help="Build with -Dclingtest=ON for Windows PR CI") parser.add_argument("--coverage", default="false", help="Create Coverage report in XML") parser.add_argument("--sha", default=None, help="sha that triggered the event") parser.add_argument("--base_ref", default=None, help="Ref to target branch") @@ -212,6 +214,7 @@ def parse_args(): # Set argument to True if matched args.incremental = args.incremental.lower() in ('yes', 'true', '1', 'on') + args.clingtest = args.clingtest.lower() in ('yes', 'true', '1', 'on') args.coverage = args.coverage.lower() in ('yes', 'true', '1', 'on') args.binaries = args.binaries.lower() in ('yes', 'true', '1', 'on') diff --git a/.github/workflows/root-ci.yml b/.github/workflows/root-ci.yml index a1bc5f18aeb4f..2d1434f7d3d7c 100644 --- a/.github/workflows/root-ci.yml +++ b/.github/workflows/root-ci.yml @@ -77,7 +77,36 @@ concurrency: cancel-in-progress: true jobs: + git_diff: + name: Detect changes in Cling + # https://www.meziantou.net/executing-github-actions-jobs-or-steps-only-when-specific-files-change.htm + runs-on: ubuntu-latest + # Declare output for next jobs + outputs: + interpreter_changed: ${{ steps.check_file_changed.outputs.interpreter_changed }} + steps: + - uses: actions/checkout@v4 + with: + # Checkout as many commits as needed for the diff + fetch-depth: 2 + - shell: pwsh + id: check_file_changed + run: | + # Diff HEAD with the latest commit of master + $diff = git diff --name-only HEAD^ HEAD + # (works with HEAD^ as the last commit fetched is virtual merge commit by GH which shows the full diff for the PR.) + + # Check if a file under interpreter/ has changed + $SourceDiff = $diff | Where-Object { $_ -match '^interpreter/' } + $HasDiff = $SourceDiff.Length -gt 0 + + # Set the output named "interpreter_changed" + Write-Host "::set-output name=interpreter_changed::$HasDiff" + #echo "interpreter_changed=$HasDiff" >> $GITHUB_OUTPUT + echo "interpreter_changed=$HasDiff" + build-macos: + needs: [ git_diff ] # For any event that is not a PR, the CI will always run. In PRs, the CI # can be skipped if the tag [skip-ci] or [skip ci] is written in the title. if: | @@ -95,18 +124,19 @@ jobs: # Common configs: {Release,Debug,RelWithDebInfo) # Build options: https://root.cern/install/build_from_source/#all-build-options include: - - platform: mac13 + - platform: mac13 arch: ARM64 overrides: ["LLVM_ENABLE_ASSERTIONS=On", "builtin_zlib=ON"] - platform: mac14 arch: X64 - overrides: ["LLVM_ENABLE_ASSERTIONS=On", "CMAKE_CXX_STANDARD=20"] + overrides: ["LLVM_ENABLE_ASSERTIONS=On", "CMAKE_CXX_STANDARD=20", "clingtest=${{needs.git_diff.outputs.interpreter_changed == 'true' && 'ON' || 'OFF'}}"] - platform: mac15 arch: ARM64 overrides: ["LLVM_ENABLE_ASSERTIONS=On", "CMAKE_CXX_STANDARD=20"] - platform: mac-beta arch: ARM64 overrides: ["LLVM_ENABLE_ASSERTIONS=On", "CMAKE_CXX_STANDARD=20"] + # https://stackoverflow.com/questions/76292948/github-action-boolean-input-with-default-value runs-on: # Using '[self-hosted, ..., ...]' does not work for some reason :) - self-hosted @@ -115,7 +145,7 @@ jobs: - ${{ matrix.platform }} name: | - ${{ matrix.platform }} ${{ matrix.arch }} + ${{ matrix.platform }} ${{ matrix.arch }} ${{ (github.event_name != 'schedule' && github.event_name != 'workflow_dispatch' && join( matrix.overrides, ', ' )) || '' }} steps: @@ -217,6 +247,7 @@ jobs: build-windows: + needs: [ git_diff ] # For any event that is not a PR, the CI will always run. In PRs, the CI # can be skipped if the tag [skip-ci] or [skip ci] is written in the title. if: | @@ -271,6 +302,7 @@ jobs: run: "C:\\setenv.bat ${{ matrix.target_arch }} && python .github/workflows/root-ci-config/build_root.py --buildtype ${{ matrix.config }} + --clingtest ${{ needs.git_diff.outputs.interpreter_changed }} --platform windows10 --incremental $INCREMENTAL --base_ref ${{ github.base_ref }} @@ -314,6 +346,7 @@ jobs: run: "C:\\setenv.bat ${{ matrix.target_arch }} && python .github/workflows/root-ci-config/build_root.py --buildtype ${{ matrix.config }} + --clingtest ${{ needs.git_diff.outputs.interpreter_changed }} --platform windows10 --incremental false --base_ref ${{ github.ref_name }} @@ -338,6 +371,7 @@ jobs: build-linux: + needs: [ git_diff ] # For any event that is not a PR, the CI will always run. In PRs, the CI # can be skipped if the tag [skip-ci] or [skip ci] is written in the title. if: | @@ -350,6 +384,11 @@ jobs: strategy: fail-fast: false matrix: + # https://github.com/orgs/community/discussions/26253 + # https://stackoverflow.com/questions/65384420/how-do-i-make-a-github-action-matrix-element-conditional + # https://stackoverflow.com/questions/68994484/how-to-skip-a-configuration-of-a-matrix-with-github-actions + # https://github.com/joaomcteixeira/python-project-skeleton/pull/31/files + # Specify image + (optional) build option overrides # # Available images: https://github.com/root-project/root-ci-images @@ -363,7 +402,8 @@ jobs: - image: alma8 overrides: ["LLVM_ENABLE_ASSERTIONS=On"] - image: alma9 - overrides: ["LLVM_ENABLE_ASSERTIONS=On", "CMAKE_BUILD_TYPE=Debug"] + overrides: ["LLVM_ENABLE_ASSERTIONS=On", "CMAKE_BUILD_TYPE=Debug", "clingtest=${{needs.git_diff.outputs.interpreter_changed == 'true' && 'ON' || 'OFF'}}"] + # https://stackoverflow.com/questions/76292948/github-action-boolean-input-with-default-value - image: ubuntu22 overrides: ["imt=Off", "LLVM_ENABLE_ASSERTIONS=On", "CMAKE_BUILD_TYPE=Debug"] - image: ubuntu2404 @@ -580,4 +620,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: Event File - path: ${{ github.event_path }} + path: ${{ github.event_path }} \ No newline at end of file diff --git a/interpreter/cling/lib/Interpreter/ValueExtractionSynthesizer.cpp b/interpreter/cling/lib/Interpreter/ValueExtractionSynthesizer.cpp index 41095fc3a9829..f3dde467b87e9 100644 --- a/interpreter/cling/lib/Interpreter/ValueExtractionSynthesizer.cpp +++ b/interpreter/cling/lib/Interpreter/ValueExtractionSynthesizer.cpp @@ -22,6 +22,14 @@ #include "clang/Sema/Sema.h" #include "clang/Sema/SemaDiagnostic.h" +// Implements the CValueExtractionPrinter interface. +extern "C" { +CLING_LIB_EXPORT +void cling_SetValueNoAlloc(void* /*cling::Value* V*/) {} +CLING_LIB_EXPORT +void cling_SetValueWithAlloc(void* /*cling::Value* V*/) {} +} + using namespace clang; namespace cling { @@ -436,6 +444,10 @@ namespace { return VSError(m_Sema, E, "cling::runtime::gCling"); if (!(NSD = utils::Lookup::Namespace(m_Sema, "internal", NSD))) return VSError(m_Sema, E, "cling::runtime::internal namespace"); + } else { + // C, ObjC,... + if (!(NSD = utils::Lookup::Namespace(m_Sema, "cling"))) + return VSError(m_Sema, E, "cling namespace"); } LookupResult R(*m_Sema, &m_Context->Idents.get("setValueNoAlloc"), SourceLocation(), Sema::LookupOrdinaryName, diff --git a/interpreter/cling/test/Driver/C.c b/interpreter/cling/test/Driver/C.c index ee302920495b4..05201877e8dd8 100644 --- a/interpreter/cling/test/Driver/C.c +++ b/interpreter/cling/test/Driver/C.c @@ -11,13 +11,13 @@ // Validate cling C mode. -// Fix value printing! - int printf(const char*,...); printf("CHECK 123 %p\n", gCling); // CHECK: CHECK 123 -12 // expected-error {{ValueExtractionSynthesizer could not find: 'cling::runtime::internal::setValueNoAlloc'.}} - -32 // expected-error {{ValueExtractionSynthesizer could not find: 'cling::runtime::internal::setValueNoAlloc'.}} +int i = 1 // CHECK: (int) 1 +sizeof(int) // CHECK: (unsigned long) 4 +int x = sizeof(int); +printf("CHECK %d\n", x); // CHECK: CHECK 4 +// expected-no-diagnostics .q