[platform] fsnotifier build for Linux: pass version to make.sh, check glibc compatibility

GitOrigin-RevId: 3b7df9f562d44ebd31c88e33657b78b009de48c6
This commit is contained in:
Vladislav Rassokhin
2022-05-23 22:21:53 +02:00
committed by intellij-monorepo-bot
parent 3e31153c47
commit a174c7d79d
2 changed files with 22 additions and 5 deletions

View File

@@ -1,8 +1,10 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#pragma once
#define VERSION "20210419.1140"
#ifndef VERSION
#define VERSION "SNAPSHOT"
#endif
#define _DEFAULT_SOURCE
#define _FILE_OFFSET_BITS 64

View File

@@ -1,14 +1,29 @@
#!/bin/bash
set -euo pipefail
VER=$(date "+%Y%m%d.%H%M")
sed -i.bak "s/#define VERSION .*/#define VERSION \"${VER}\"/" fsnotifier.h && rm fsnotifier.h.bak
VER="${1:-}"
if [ -z "${VER:-}" ]; then
VER=$(date "+%Y%m%d.%H%M")
fi
ARCH=$(uname -m)
# To make sure it's compatible with old Linux distributions, e.g. CentOS 7
max_allowed_glibc_version="2.17"
build_fsnotifier() {
[ -f "$1" ] && rm "$1"
${CC:-clang} -O2 -Wall -Wextra -Wpedantic -std=c11 main.c inotify.c util.c -o "$1"
${CC:-clang} -O2 -Wall -Wextra -Wpedantic -D "VERSION=\"$VER\"" -std=c11 main.c inotify.c util.c -o "$1"
chmod 755 "$1"
echo "Checking $1 for glibc version compatibility..."
glibc_version="$(objdump -x "$1" | grep -o "GLIBC_.*" | sort | uniq | cut -d _ -f 2 | sort -V | tail -n 1)"
newest=$(printf "%s\n%s\n" "$max_allowed_glibc_version" "$glibc_version" | sort -V | tail -n 1)
if [ "$newest" != "$max_allowed_glibc_version" ]; then
echo "ERROR: $1 uses glibc version $glibc_version which is newer than $max_allowed_glibc_version"
exit 1
else
echo "OK: $1 uses glibc version $glibc_version"
fi
}
if [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "amd64" ]; then