Skip to content

Commit aeef6ca

Browse files
committed
[GR-68707] Remove AMD64.CPUFeature.HT from build time CPU features
PullRequest: graal/21859
2 parents 4192231 + b5a5798 commit aeef6ca

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/AMD64CPUFeatureAccessFeature.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -33,8 +33,8 @@
3333
import com.oracle.svm.core.SubstrateTargetDescription;
3434
import com.oracle.svm.core.amd64.AMD64CPUFeatureAccess;
3535
import com.oracle.svm.core.amd64.AMD64LibCHelper;
36-
import com.oracle.svm.core.feature.InternalFeature;
3736
import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
37+
import com.oracle.svm.core.feature.InternalFeature;
3838

3939
import jdk.vm.ci.amd64.AMD64;
4040

@@ -46,12 +46,25 @@ public class AMD64CPUFeatureAccessFeature extends CPUFeatureAccessFeatureBase im
4646
public void beforeAnalysis(BeforeAnalysisAccess arg) {
4747
var targetDescription = ImageSingletons.lookup(SubstrateTargetDescription.class);
4848
var arch = (AMD64) targetDescription.arch;
49-
var buildtimeCPUFeatures = arch.getFeatures();
49+
var buildtimeCPUFeatures = filterFeatures(arch.getFeatures());
5050
initializeCPUFeatureAccessData(AMD64.CPUFeature.values(), buildtimeCPUFeatures, AMD64LibCHelper.CPUFeatures.class, (FeatureImpl.BeforeAnalysisAccessImpl) arg);
5151
}
5252

5353
@Override
5454
protected AMD64CPUFeatureAccess createCPUFeatureAccessSingleton(EnumSet<?> buildtimeCPUFeatures, int[] offsets, byte[] errorMessageBytes, byte[] buildtimeFeatureMaskBytes) {
5555
return new AMD64CPUFeatureAccess(buildtimeCPUFeatures, offsets, errorMessageBytes, buildtimeFeatureMaskBytes);
5656
}
57+
58+
/** Returns a copy of {@code features}, with some unwanted features removed. */
59+
private static EnumSet<AMD64.CPUFeature> filterFeatures(EnumSet<AMD64.CPUFeature> features) {
60+
var ret = EnumSet.copyOf(features);
61+
/*
62+
* GR-68707: Intel P-cores and E-cores may differ in the presence of the HT feature. This
63+
* could cause the runtime CPU feature check to fail on hybrid CPUs if an image is built
64+
* with --march=native, the build time checking happens on a P-core, but the runtime
65+
* checking is done on an E-core, even on the same machine.
66+
*/
67+
ret.remove(AMD64.CPUFeature.HT);
68+
return ret;
69+
}
5770
}

0 commit comments

Comments
 (0)