From a174c7d79db664b9a8946f7ceb9e88a9fcd97919 Mon Sep 17 00:00:00 2001 From: Vladislav Rassokhin Date: Mon, 23 May 2022 22:21:53 +0200 Subject: [PATCH] [platform] fsnotifier build for Linux: pass version to make.sh, check glibc compatibility GitOrigin-RevId: 3b7df9f562d44ebd31c88e33657b78b009de48c6 --- native/fsNotifier/linux/fsnotifier.h | 6 ++++-- native/fsNotifier/linux/make.sh | 21 ++++++++++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/native/fsNotifier/linux/fsnotifier.h b/native/fsNotifier/linux/fsnotifier.h index 30f1aec053c5..d5fec6261ac3 100644 --- a/native/fsNotifier/linux/fsnotifier.h +++ b/native/fsNotifier/linux/fsnotifier.h @@ -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 diff --git a/native/fsNotifier/linux/make.sh b/native/fsNotifier/linux/make.sh index 38e9c262c678..a349548beafc 100755 --- a/native/fsNotifier/linux/make.sh +++ b/native/fsNotifier/linux/make.sh @@ -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