Skip to content

Commit 0cc049d

Browse files
retaseth-priya
andcommitted
add support for ppc64le architecture (opensearch-project#5459) (opensearch-project#6224)
Signed-off-by: Andriy Redko <andriy.redko@aiven.io> Co-authored-by: Priya Seth <sethp@us.ibm.com>
1 parent 1007831 commit 0cc049d

File tree

13 files changed

+127
-5
lines changed

13 files changed

+127
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
55
## [Unreleased 1.3.x]
66
- Bumps `Netty` from 4.1.86.Final to 4.1.87.Final ([#6130](https://github.com/opensearch-project/OpenSearch/pull/6130))
77
- Bumps `Jackson` from 2.14.1 to 2.14.2 ([#6129](https://github.com/opensearch-project/OpenSearch/pull/6129))
8+
- Add support for ppc64le architecture ([#5459](https://github.com/opensearch-project/OpenSearch/pull/5459))
89

910
### Added
1011
### Dependencies

buildSrc/src/main/java/org/opensearch/gradle/Architecture.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
public enum Architecture {
3636

3737
X64,
38-
ARM64;
38+
ARM64,
39+
PPC64LE;
3940

4041
public static Architecture current() {
4142
final String architecture = System.getProperty("os.arch", "");
@@ -45,6 +46,8 @@ public static Architecture current() {
4546
return X64;
4647
case "aarch64":
4748
return ARM64;
49+
case "ppc64le":
50+
return PPC64LE;
4851
default:
4952
throw new IllegalArgumentException("can not determine architecture from [" + architecture + "]");
5053
}

buildSrc/src/main/java/org/opensearch/gradle/DistributionDownloadPlugin.java

+3
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ private String dependencyNotation(OpenSearchDistribution distribution) {
241241
case X64:
242242
classifier = ":" + distribution.getPlatform() + "-x64";
243243
break;
244+
case PPC64LE:
245+
classifier = ":" + distribution.getPlatform() + "-ppc64le";
246+
break;
244247
default:
245248
throw new IllegalArgumentException("Unsupported architecture: " + distribution.getArchitecture());
246249
}

buildSrc/src/main/java/org/opensearch/gradle/Jdk.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
public class Jdk implements Buildable, Iterable<File> {
5050

51-
private static final List<String> ALLOWED_ARCHITECTURES = Collections.unmodifiableList(Arrays.asList("aarch64", "x64"));
51+
private static final List<String> ALLOWED_ARCHITECTURES = Collections.unmodifiableList(Arrays.asList("aarch64", "x64", "ppc64le"));
5252
private static final List<String> ALLOWED_VENDORS = Collections.unmodifiableList(Arrays.asList("adoptium", "adoptopenjdk", "openjdk"));
5353
private static final List<String> ALLOWED_PLATFORMS = Collections.unmodifiableList(
5454
Arrays.asList("darwin", "freebsd", "linux", "mac", "windows")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
package org.opensearch.gradle;
10+
11+
import org.opensearch.gradle.test.GradleUnitTestCase;
12+
13+
public class ArchitectureTests extends GradleUnitTestCase {
14+
15+
final String architecture = System.getProperty("os.arch", "");
16+
17+
public void testCurrentArchitecture() {
18+
assertEquals(Architecture.X64, currentArchitecture("amd64"));
19+
assertEquals(Architecture.X64, currentArchitecture("x86_64"));
20+
assertEquals(Architecture.ARM64, currentArchitecture("aarch64"));
21+
assertEquals(Architecture.PPC64LE, currentArchitecture("ppc64le"));
22+
}
23+
24+
public void testInvalidCurrentArchitecture() {
25+
assertThrows("can not determine architecture from [", IllegalArgumentException.class, () -> currentArchitecture("fooBar64"));
26+
}
27+
28+
/**
29+
* Determines the return value of {@link Architecture#current()} based on a string representing a potential OS Architecture.
30+
*
31+
* @param osArchToTest An expected value of the {@code os.arch} system property on another architecture.
32+
* @return the value of the {@link Architecture} enum which would have resulted with the given value.
33+
* @throws IllegalArgumentException if the string is not mapped to a value of the {@link Architecture} enum.
34+
*/
35+
private Architecture currentArchitecture(String osArchToTest) throws IllegalArgumentException {
36+
// Test new architecture
37+
System.setProperty("os.arch", osArchToTest);
38+
try {
39+
return Architecture.current();
40+
} finally {
41+
// Restore actual architecture property value
42+
System.setProperty("os.arch", this.architecture);
43+
}
44+
}
45+
}

buildSrc/src/test/java/org/opensearch/gradle/JdkDownloadPluginTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void testUnknownArchitecture() {
108108
"11.0.2+33",
109109
"linux",
110110
"unknown",
111-
"unknown architecture [unknown] for jdk [testjdk], must be one of [aarch64, x64]"
111+
"unknown architecture [unknown] for jdk [testjdk], must be one of [aarch64, x64, ppc64le]"
112112
);
113113
}
114114

distribution/archives/build.gradle

+30
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,27 @@ distribution_archives {
9595
}
9696
}
9797

98+
darwinArm64Tar {
99+
archiveClassifier = 'darwin-arm64'
100+
content {
101+
archiveFiles(modulesFiles('darwin-arm64'), 'tar', 'darwin', 'arm64', true)
102+
}
103+
}
104+
98105
noJdkDarwinTar {
99106
archiveClassifier = 'no-jdk-darwin-x64'
100107
content {
101108
archiveFiles(modulesFiles('darwin-x64'), 'tar', 'darwin', 'x64', false)
102109
}
103110
}
104111

112+
noJdkDarwinArm64Tar {
113+
archiveClassifier = 'no-jdk-darwin-arm64'
114+
content {
115+
archiveFiles(modulesFiles('darwin-arm64'), 'tar', 'darwin', 'arm64', false)
116+
}
117+
}
118+
105119
freebsdTar {
106120
archiveClassifier = 'freebsd-x64'
107121
content {
@@ -137,6 +151,22 @@ distribution_archives {
137151
}
138152
}
139153

154+
noJdkLinuxArm64Tar {
155+
archiveClassifier = 'no-jdk-linux-arm64'
156+
content {
157+
archiveFiles(modulesFiles('linux-arm64'), 'tar', 'linux', 'arm64', false)
158+
}
159+
}
160+
161+
// Should really be `no-jdk-linux-ppc64le` as it ships without a JDK, however it seems that the build can't handle
162+
// the absence of the `linux-ppc64le` target.
163+
linuxPpc64leTar {
164+
archiveClassifier = 'linux-ppc64le'
165+
content {
166+
archiveFiles(modulesFiles('linux-ppc64le'), 'tar', 'linux', 'ppc64le', false)
167+
}
168+
}
169+
140170
windowsZip {
141171
archiveClassifier = 'windows-x64'
142172
content {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*
8+
* Modifications Copyright OpenSearch Contributors. See
9+
* GitHub history for details.
10+
*/
11+
12+
// This file is intentionally blank. All configuration of the
13+
// distribution is done in the parent project.
14+

distribution/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
252252
// Setup all required JDKs
253253
project.jdks {
254254
['darwin', 'linux', 'windows'].each { platform ->
255-
(platform == 'linux' ? ['x64', 'aarch64'] : ['x64']).each { architecture ->
255+
(platform == 'linux' || platform == 'darwin' ? ['x64', 'aarch64', 'ppc64le'] : ['x64']).each { architecture ->
256256
"bundled_${platform}_${architecture}" {
257257
it.platform = platform
258258
it.version = VersionProperties.getBundledJdk(platform)
@@ -325,7 +325,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
325325
}
326326
}
327327
def buildModules = buildModulesTaskProvider
328-
List excludePlatforms = ['darwin-x64', 'freebsd-x64', 'linux-x64', 'linux-arm64', 'windows-x64']
328+
List excludePlatforms = ['darwin-x64', 'freebsd-x64', 'linux-x64', 'linux-arm64', 'linux-ppc64le', 'windows-x64', 'darwin-arm64']
329329
if (platform != null) {
330330
excludePlatforms.remove(excludePlatforms.indexOf(platform))
331331
} else {

distribution/docker/build.gradle

+8
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ testFixtures.useFixture()
2727

2828
configurations {
2929
arm64DockerSource
30+
ppc64leDockerSource
3031
dockerSource
3132
}
3233

3334
dependencies {
3435
arm64DockerSource project(path: ":distribution:archives:linux-arm64-tar", configuration:"default")
36+
ppc64leDockerSource project(path: ":distribution:archives:linux-ppc64le-tar", configuration:"default")
3537
dockerSource project(path: ":distribution:archives:linux-tar", configuration:"default")
3638
}
3739

@@ -42,6 +44,8 @@ ext.expansions = { Architecture architecture, DockerBase base, boolean local ->
4244
classifier = "linux-arm64"
4345
} else if (architecture == Architecture.X64) {
4446
classifier = "linux-x64"
47+
} else if (architecture == Architecture.PPC64LE) {
48+
classifier = "linux-ppc64le"
4549
} else {
4650
throw new IllegalArgumentException("Unsupported architecture [" + architecture + "]")
4751
}
@@ -85,12 +89,14 @@ RUN curl --retry 8 -S -L \\
8589
private static String buildPath(Architecture architecture, DockerBase base) {
8690
return 'build/' +
8791
(architecture == Architecture.ARM64 ? 'arm64-' : '') +
92+
(architecture == Architecture.PPC64LE ? 'ppc64le-' : '') +
8893
'docker'
8994
}
9095

9196
private static String taskName(String prefix, Architecture architecture, DockerBase base, String suffix) {
9297
return prefix +
9398
(architecture == Architecture.ARM64 ? 'Arm64' : '') +
99+
(architecture == Architecture.PPC64LE ? 'Ppc64le' : '') +
94100
suffix
95101
}
96102

@@ -127,6 +133,8 @@ void addCopyDockerContextTask(Architecture architecture, DockerBase base) {
127133

128134
if (architecture == Architecture.ARM64) {
129135
from configurations.arm64DockerSource
136+
} else if (architecture == Architecture.PPC64LE) {
137+
from configurations.ppc64leDockerSource
130138
} else {
131139
from configurations.dockerSource
132140
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* The OpenSearch Contributors require contributions made to
6+
* this file be licensed under the Apache-2.0 license or a
7+
* compatible open source license.
8+
*
9+
*/
10+
11+
// This file is intentionally blank. All configuration of the
12+
// export is done in the parent project.

server/src/main/java/org/opensearch/bootstrap/SystemCallFilter.java

+1
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ static class Arch {
257257
Map<String, Arch> m = new HashMap<>();
258258
m.put("amd64", new Arch(0xC000003E, 0x3FFFFFFF, 57, 58, 59, 322, 317));
259259
m.put("aarch64", new Arch(0xC00000B7, 0xFFFFFFFF, 1079, 1071, 221, 281, 277));
260+
m.put("ppc64le", new Arch(0xC0000015, 0xFFFFFFFF, 2, 189, 11, 362, 358));
260261
ARCHITECTURES = Collections.unmodifiableMap(m);
261262
}
262263

settings.gradle

+5
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,20 @@ List projects = [
3939
'distribution:archives:windows-zip',
4040
'distribution:archives:no-jdk-windows-zip',
4141
'distribution:archives:darwin-tar',
42+
'distribution:archives:darwin-arm64-tar',
43+
'distribution:archives:no-jdk-darwin-arm64-tar',
4244
'distribution:archives:no-jdk-darwin-tar',
4345
'distribution:archives:freebsd-tar',
4446
'distribution:archives:no-jdk-freebsd-tar',
4547
'distribution:archives:linux-arm64-tar',
48+
'distribution:archives:no-jdk-linux-arm64-tar',
49+
'distribution:archives:linux-ppc64le-tar',
4650
'distribution:archives:linux-tar',
4751
'distribution:archives:no-jdk-linux-tar',
4852
'distribution:docker',
4953
'distribution:docker:docker-arm64-build-context',
5054
'distribution:docker:docker-arm64-export',
55+
'distribution:docker:docker-ppc64le-export',
5156
'distribution:docker:docker-build-context',
5257
'distribution:docker:docker-export',
5358
'distribution:packages:arm64-deb',

0 commit comments

Comments
 (0)