Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ClangAstParser/clang-dumper-release.tag
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18.1.8_2
v18.1.8_4
7 changes: 6 additions & 1 deletion ClangAstParser/src/pt/up/fe/specs/clang/ClangResources.java
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,14 @@ private File findSystemClangResourceDir(Integer llvmMajor) {

var expectedVersion = llvmMajor == null ? "the local clang-dumper build's version"
: "LLVM " + llvmMajor;
var installHint = llvmMajor == null ? "clang++" : "clang++-" + llvmMajor;
throw new RuntimeException("Could not find a system Clang resource directory for SYSTEM mode with built-in CUDA"
+ " on host '" + SupportedPlatform.getCurrentPlatform() + "' (expected " + expectedVersion
+ "). Tried: " + commandNames);
+ "). Tried: " + commandNames
+ ". SYSTEM mode does not bundle Clang's CUDA wrapper headers, so a matching system Clang"
+ " installation is required: install '" + installHint + "' (e.g. 'apt install " + installHint
+ "' or 'brew install llvm'), or set the libc mode to 'builtin' to use the bundled includes"
+ " instead of the system libc");
}

private static List<String> getSystemClangCommandNames(Integer llvmMajor) {
Expand Down
44 changes: 17 additions & 27 deletions ClangAstParser/src/pt/up/fe/specs/clang/CudaResources.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
* the bundled dumper.
*
* <p>CUDA resources are release-addressed. The published release directory is the complete CUDA installation;
* manifests and downloaded archives used to build it live in staging until that directory is published.</p>
* manifests and downloaded archives used to build it live in staging until that directory is published. The
* redistribution manifest itself is cached at {@code <cache>/cuda/redistrib_<release>.json} and reused across calls.</p>
*/
final class CudaResources {

Expand Down Expand Up @@ -117,15 +118,17 @@ static boolean isSupportedPlatform(Path cacheRoot) {
}

static boolean isSupportedPlatform(Path cacheRoot, FileResourceProvider manifestResource) {
return findSupportedPlatform(getCurrentManifest(cacheRoot, manifestResource)).isPresent();
return findSupportedPlatform(readManifest(cacheRoot, ClangAstWebResource.getCudaReleaseTag(),
manifestResource)).isPresent();
}

static CudaPlatform getCurrentPlatform() {
return getCurrentPlatform(ClangResources.getDefaultTempFolder().toPath());
}

static CudaPlatform getCurrentPlatform(Path cacheRoot) {
return requireSupportedPlatform(getCurrentManifest(cacheRoot));
var releaseTag = ClangAstWebResource.getCudaReleaseTag();
return requireSupportedPlatform(readManifest(cacheRoot, releaseTag, getManifestResource(releaseTag)));
}

static CudaPlatform getCurrentPlatform(NvidiaCudaManifest manifest) {
Expand Down Expand Up @@ -183,30 +186,17 @@ private static RuntimeException unsupportedPlatform(NvidiaCudaManifest manifest,
+ ". Available manifest platform keys: " + getAvailablePlatformKeys(manifest));
}

private static NvidiaCudaManifest getCurrentManifest(Path cacheRoot) {
var releaseTag = ClangAstWebResource.getCudaReleaseTag();
return getCurrentManifest(cacheRoot, releaseTag, getManifestResource(releaseTag));
}

private static NvidiaCudaManifest getCurrentManifest(Path cacheRoot, FileResourceProvider manifestResource) {
var releaseTag = ClangAstWebResource.getCudaReleaseTag();
return getCurrentManifest(cacheRoot, releaseTag, manifestResource);
}

private static NvidiaCudaManifest getCurrentManifest(Path cacheRoot, String releaseTag,
FileResourceProvider manifestResource) {
var cudaRoot = cacheRoot.resolve(CUDA_FOLDERNAME);
CacheFiles.deleteUnlockedStagingLocks(cacheRoot, cudaRoot);
var stagingDirectory = CacheFiles.createStagingDirectory(cacheRoot, cudaRoot, "." + releaseTag + ".tmp-");
try {
return downloadManifest(cacheRoot, stagingDirectory.path(), releaseTag, manifestResource);
} finally {
try {
CacheFiles.delete(stagingDirectory.path());
} finally {
stagingDirectory.close();
}
}
// The manifest is installed to a stable cache path and reused across calls, so platform checks and the like do
// not re-download it on every invocation. Mirrors how ClangAstWebResource.getManifest caches the clang-dumper
// release manifest.
private static NvidiaCudaManifest readManifest(Path cacheRoot, String releaseTag,
FileResourceProvider manifestResource) {
var manifestFile = CacheFiles.installFile(cacheRoot,
cacheRoot.resolve(CUDA_FOLDERNAME).resolve(getManifestFilename(releaseTag)).toFile(),
manifestResource, null, "NVIDIA CUDA redistribution manifest");
var manifest = parseManifest(SpecsIo.read(manifestFile));
validateManifest(manifest, releaseTag);
return manifest;
}

private static boolean isCompatiblePlatform(String manifestPlatform, SupportedPlatform hostPlatform,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import pt.up.fe.specs.clava.ast.expr.data.designator.Designator;
import pt.up.fe.specs.clava.ast.expr.data.designator.FieldDesignator;
import pt.up.fe.specs.clava.ast.expr.data.offsetof.OffsetOfArray;
import pt.up.fe.specs.clava.ast.expr.data.offsetof.OffsetOfBase;
import pt.up.fe.specs.clava.ast.expr.data.offsetof.OffsetOfComponent;
import pt.up.fe.specs.clava.ast.expr.data.offsetof.OffsetOfComponentKind;
import pt.up.fe.specs.clava.ast.expr.data.offsetof.OffsetOfField;
Expand Down Expand Up @@ -459,6 +460,9 @@ public static OffsetOfComponent offsetOfComponent(LineStream lines, ClangAstData
case IDENTIFIER:
component.set(OffsetOfIdentifier.FIELD_NAME, lines.nextLine());
break;
case BASE:
parserData.getClavaNodes().queueSetNode(component, OffsetOfBase.TYPE, lines.nextLine());
break;
default:
throw new NotImplementedException(kind);
}
Expand Down
16 changes: 9 additions & 7 deletions ClavaAst/src/pt/up/fe/specs/clava/ast/expr/OffsetOfExpr.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,20 @@ private String getComponentsCode() {

StringBuilder code = new StringBuilder();

boolean isFirst = true;
boolean hasCode = false;
for (OffsetOfComponent component : get(COMPONENTS)) {
String componentCode = component.getCode();

if (component.isField() && !isFirst) {
code.append(".");
if (componentCode.isEmpty()) {
continue;
}

code.append(component.getCode());

if (isFirst) {
isFirst = false;
if (component.isField() && hasCode) {
code.append(".");
}

code.append(componentCode);
hasCode = true;
}
return code.toString();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright 2026 SPeCS.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/

package pt.up.fe.specs.clava.ast.expr.data.offsetof;

import org.suikasoft.jOptions.Datakey.DataKey;
import org.suikasoft.jOptions.Datakey.KeyFactory;

import pt.up.fe.specs.clava.ast.type.Type;

public class OffsetOfBase extends OffsetOfComponent {

/// DATAKEYS BEGIN

public final static DataKey<Type> TYPE = KeyFactory.object("type", Type.class);

/// DATAKEYS END

@Override
public String getCode() {
// Clang adds the base to the semantic path, but it is not part of the source designator.
return "";
}

@Override
public OffsetOfComponentKind getKind() {
return OffsetOfComponentKind.BASE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public static OffsetOfComponent newInstance(OffsetOfComponentKind kind) {
return new OffsetOfField();
case IDENTIFIER:
return new OffsetOfIdentifier();
case BASE:
return new OffsetOfBase();
default:
throw new NotImplementedException(kind);
}
Expand Down
Loading