Skip to content

Commit b78a28c

Browse files
committed
Add ppc64le support
1 parent af5cbce commit b78a28c

File tree

7 files changed

+42
-19
lines changed

7 files changed

+42
-19
lines changed

Makefile

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,6 @@ export DEBUG_DIR ?= $(CURDIR)/.debug
3636

3737
include $(MAKE_DIR)/common.mk
3838

39-
DATE := $(shell date -u --iso-8601=minutes)
40-
REVISION := $(shell git rev-parse HEAD)
41-
COMPILER := $(realpath $(shell which $(CC)))
42-
43-
ifeq ($(DATE),)
44-
$(error Invalid date format)
45-
endif
46-
ifeq ($(REVISION),)
47-
$(error Invalid commit hash)
48-
endif
49-
ifeq ($(COMPILER),)
50-
$(error Invalid compiler)
51-
endif
52-
5339
##### File definitions #####
5440

5541
DOC_FILES := $(CURDIR)/NOTICE \
@@ -94,11 +80,7 @@ BIN_SCRIPT = $(SRCS_DIR)/cli/$(BIN_NAME).lds
9480

9581
##### Target definitions #####
9682

97-
ifneq ($(wildcard /etc/debian_version),)
98-
ARCH ?= amd64
99-
else
100-
ARCH ?= x86_64
101-
endif
83+
ARCH ?= $(call getarch)
10284
MAJOR := $(call getdef,NVC_MAJOR,$(LIB_INCS))
10385
MINOR := $(call getdef,NVC_MINOR,$(LIB_INCS))
10486
PATCH := $(call getdef,NVC_PATCH,$(LIB_INCS))
@@ -185,6 +167,7 @@ $(BUILD_DEFS):
185167
@printf '#define BUILD_COMPILER "%s " __VERSION__\n' '$(notdir $(COMPILER))' >>$(BUILD_DEFS)
186168
@printf '#define BUILD_FLAGS "%s"\n' '$(strip $(CPPFLAGS) $(CFLAGS) $(LDFLAGS))' >>$(BUILD_DEFS)
187169
@printf '#define BUILD_REVISION "%s"\n' '$(strip $(REVISION))' >>$(BUILD_DEFS)
170+
@printf '#define BUILD_PLATFORM "%s"\n' '$(strip $(PLATFORM))' >>$(BUILD_DEFS)
188171

189172
$(LIB_RPC_SRCS): $(LIB_RPC_SPEC)
190173
$(RM) $@

mk/common.mk

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved.
33
#
44

5+
##### Global definitions #####
6+
57
MV ?= mv -f
68
CP ?= cp -a
79
LN ?= ln
@@ -15,4 +17,29 @@ OBJCPY ?= objcopy
1517
RPCGEN ?= rpcgen
1618
BMAKE ?= MAKEFLAGS= bmake
1719

20+
DATE := $(shell date -u --iso-8601=minutes)
21+
REVISION := $(shell git rev-parse HEAD)
22+
COMPILER := $(realpath $(shell which $(CC)))
23+
PLATFORM ?= $(shell uname -p)
24+
25+
ifeq ($(DATE),)
26+
$(error Invalid date format)
27+
endif
28+
ifeq ($(REVISION),)
29+
$(error Invalid commit hash)
30+
endif
31+
ifeq ($(COMPILER),)
32+
$(error Invalid compiler)
33+
endif
34+
35+
##### Function definitions #####
36+
1837
getdef = $(shell sed -n "0,/$(1)/s/\#define\s\+$(1)\s\+\(\w*\)/\1/p" $(2))
38+
39+
ifeq ($(PLATFORM),x86_64)
40+
getarch = $(shell [ -f /etc/debian_version ] && echo "amd64" || echo "x86_64")
41+
else ifeq ($(PLATFORM),ppc64le)
42+
getarch = $(shell [ -f /etc/debian_version ] && echo "ppc64el" || echo "ppc64le")
43+
else
44+
$(error Unsupported architecture)
45+
endif

src/cli/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ print_version(FILE *stream, maybe_unused struct argp_state *state)
5757
fprintf(stream, "build date: %s\n", BUILD_DATE);
5858
fprintf(stream, "build revision: %s\n", BUILD_REVISION);
5959
fprintf(stream, "build compiler: %s\n", BUILD_COMPILER);
60+
fprintf(stream, "build platform: %s\n", BUILD_PLATFORM);
6061
fprintf(stream, "build flags: %s\n", BUILD_FLAGS);
6162
}
6263

src/common.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
# define LIB32_ARCH LD_I386_LIB32
3535
# define USR_LIB_MULTIARCH_DIR "/usr/lib/x86_64-linux-gnu"
3636
# define USR_LIB32_MULTIARCH_DIR "/usr/lib/i386-linux-gnu"
37+
#elif defined(__powerpc64__)
38+
# define LIB_ARCH LD_POWERPC_LIB64
39+
# define LIB32_ARCH LD_UNKNOWN
40+
# define USR_LIB_MULTIARCH_DIR "/usr/lib/powerpc64le-linux-gnu"
41+
# define USR_LIB32_MULTIARCH_DIR "/var/empty"
3742
#else
3843
# error "unsupported architecture"
3944
#endif /* defined(__x86_64__) */

src/ldcache.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ struct ldcache {
1919
};
2020

2121
enum {
22+
LD_UNKNOWN = (uint32_t)-1,
23+
2224
LD_TYPE_MASK = 0x00ff,
2325
LD_ELF = 0x0001,
2426
LD_ELF_LIBC5 = 0x0002,

src/nvc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ nvc_entrypoint(void)
5454
printf("build date: %s\n", BUILD_DATE);
5555
printf("build revision: %s\n", BUILD_REVISION);
5656
printf("build compiler: %s\n", BUILD_COMPILER);
57+
printf("build platform: %s\n", BUILD_PLATFORM);
5758
printf("build flags: %s\n", BUILD_FLAGS);
5859
exit(EXIT_SUCCESS);
5960
}

src/options.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ enum {
5959
OPT_GRAPHICS_LIBS = 1 << 7,
6060
OPT_UTILITY_BINS = 1 << 8,
6161
OPT_COMPUTE_BINS = 1 << 9,
62+
#if defined(__powerpc64__) /* ppc64le doesn't support compat32. */
63+
OPT_COMPAT32 = 1 << 0,
64+
#else
6265
OPT_COMPAT32 = 1 << 10,
66+
#endif /* defined(__powerpc64__) */
6367
};
6468

6569
static const struct option container_opts[] = {

0 commit comments

Comments
 (0)