Skip to content

Commit cdca470

Browse files
authored
Workaround missing version info in cproc (#17)
Apply simply patch to cproc to have it support --version. Version info is simply the SHA1 used for building the compiler. fixes compiler-explorer/compiler-explorer#3035 Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
1 parent 2de16dc commit cdca470

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

build/build-cproc.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ pushd build-cproc
5353
git clone --depth 1 "${URL}" --branch "${BRANCH}"
5454
pushd cproc
5555

56+
## Temporary (hopefully) patch to support basic --version
57+
git am ../../cproc-version.patch
58+
5659
./configure
5760

5861
git submodule update --init --recursive

build/cproc-version.patch

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
From 096c248718795c4b52df47dc16941615e6806a5c Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= <dkm@kataplop.net>
3+
Date: Tue, 19 Oct 2021 22:04:34 +0200
4+
Subject: [PATCH] Supports for getting version with --version
5+
MIME-Version: 1.0
6+
Content-Type: text/plain; charset=UTF-8
7+
Content-Transfer-Encoding: 8bit
8+
9+
Very basic support for getting version with --version. Currently configure gets
10+
the current SHA1 from the git repository and use this as version.
11+
12+
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
13+
---
14+
configure | 6 ++++++
15+
driver.c | 10 ++++++++++
16+
2 files changed, 16 insertions(+)
17+
18+
diff --git a/configure b/configure
19+
index be7a95b..615b23e 100755
20+
--- a/configure
21+
+++ b/configure
22+
@@ -164,6 +164,12 @@ static const char *const linkcmd[] = {"$DEFAULT_LINKER", $linkflags};
23+
EOF
24+
echo done
25+
26+
+VERSION_STRING=$(git rev-parse HEAD)
27+
+printf "creating version.h..."
28+
+cat >version.h <<EOF
29+
+#define VERSION_STRING "$VERSION_STRING"
30+
+EOF
31+
+
32+
printf "creating config.mk... "
33+
cat >config.mk <<EOF
34+
PREFIX=$prefix
35+
diff --git a/driver.c b/driver.c
36+
index 441078e..7996b92 100644
37+
--- a/driver.c
38+
+++ b/driver.c
39+
@@ -16,6 +16,7 @@
40+
#include <unistd.h>
41+
42+
#include "util.h"
43+
+#include "version.h"
44+
45+
enum filetype {
46+
NONE, /* detect based on file extension */
47+
@@ -64,6 +65,13 @@ static struct stageinfo stages[] = {
48+
[LINK] = {.name = "link"},
49+
};
50+
51+
+static void
52+
+version(void)
53+
+{
54+
+ fprintf(stderr, "version: " VERSION_STRING "\n");
55+
+ exit(2);
56+
+}
57+
+
58+
static void
59+
usage(const char *fmt, ...)
60+
{
61+
@@ -448,6 +456,8 @@ main(int argc, char *argv[])
62+
} else if (strcmp(arg, "-pthread") == 0) {
63+
arrayaddptr(&stages[LINK].cmd, "-l");
64+
arrayaddptr(&stages[LINK].cmd, "pthread");
65+
+ } else if (strcmp(arg, "--version") == 0) {
66+
+ version();
67+
} else {
68+
if (arg[2] != '\0' && strchr("cESsv", arg[1]))
69+
usage(NULL);
70+
--
71+
2.33.0
72+

0 commit comments

Comments
 (0)