Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build a Development Environment with Source Code Compiler BeeGFS

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article is about how to build a development environment using source code compilation BeeGFS. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

If we need to debug and develop BeeGFS dynamically, we need to compile it manually and be able to run it in the simplest way. Here's how to explore and analyze it.

Initialize the environment

Install dependent packages:

$yum install-y libuuid-devel libibverbs-devel librdmacm-devel libattr-devel redhat-rpm-config rpm-build xfsprogs-devel cppunit cppunit-devel zlib-devel openssl-devel sqlite sqlite-devel ant gcc-c++ gcc redhat-lsb-core java-devel to get the official source code

Get the source code of the specified version:

$git clone https://git.beegfs.io/pub/v6.git beegfs-v6 $cd beegfs-v6 $git tag-l6.16.106.116.126.136.146.156.166.176.186.196.26.36.46.56.66.76.86.9$ git checkout-b v6.18 6.18

Do a simple review and verification:

$git show 6.18 | head-n12tag 6.18Tagger: Bernd Lietzow Date: Mon Mar 12 16:09:35 2018 + 0100created tag 6.18commit aee03250ea19502952d2f187e73134996abaec5bAuthor: Bernd Lietzow Date: Mon Mar 12 16:09:13 2018 + 0100 updated to release 6.18$ git branch-av master 4a69532 updated to release 6.19 * v6.18 aee0325 updated to release 6.18 remotes/origin/HEAD-> origin/master remotes/origin/master 4a69532 updated to release 6.19 Analysis Makefile

Check out his Makefile,BeeGFS to implement a simple Makefile project template. All sub-modules use this set of templates to mutate, which is very simple and efficient:

$make-j$ (nproc)-C beegfs_meta/build help [VER] BEEGFS_VERSION= "19.5-git8" BEEGFS_VERSION_CODE=18023688make: Entering directory `/ root/beegfs-v6/fhgfs_meta/build'Optional arguments: BEEGFS_DEBUG=1 Enables debug information and symbols BEEGFS_DEBUG_OPT=1 Enables internal debug code But compiled with optimizations CXX= Specifies a C++ compiler DISTCC=distcc Enables the usage of distcc Veter1 Print command lines of tool invocations BEEGFS_COMMON_PATH= Path to the beegfs_common directory BEEGFS_OPENTK_PATH= Path to the beegfs_opentk_lib directory BEEGFS_THIRDPARTY_PATH= Path to the beegfs_thirdparty directoryTargets: all (default) build Only clean delete compiled files help print this help message rpm create an rpm package deb create debian package filemake: Leaving directory `/ root/beegfs-v6/fhgfs_meta/build'$ cat beegfs_meta/build/Makefile# This is the beegfs_meta makefile.# It creates an ELF executable.# # Use "make help" to find out about configuration options.CAN_PACKAGE: = yesinclude $(or $(root-dir)) .. /..) / build/Makefile$ (call build-executable,\ beegfs-meta,\ $(shell find.. / source-iname'* .cpp'),\ opentk common cppunit dl) # enable special reference DirInode debug codeifneq ($(BEEGFS_DEBUG_RELEASE_DIR),) # extra release dir debugging CXXFLAGS + =-DBEEGFS_DEBUG_RELEASE_DIRendif$ cat build/Makefile...override V: = $(if$ V) @) all:...rpm:. / make-rpm...# build-executable## define a new executable for the build# arguments:# # 1: name of the executable## 2: sources# # 3: required librariesbuild-executable = $(eval $(call-build-executable-fragment,$ (strip $1), $2) define-build-executable-fragmentall: $1CLEANUP_FILES + = $1 $(addsuffix .o, $2) $(addsuffix .d, $2) $(addsuffix .o) 2): CXXFLAGS + =\ $(foreach lib,$3,$ (call resolve-dep-cflags,$ (lib) $1: LDFLAGS + =\-Wl,--start-group $(foreach lib,$3,$ (call resolve-dep-ldflags,$ (lib)-Wl,--end-group$1: $(addsuffix .o, $2) $(foreach lib,$3,$ (call resolve-dep-deps) $(lib)) @ echo "[LD] $$@" $$CXX $(CXX)-o $@ $(addsuffix .o, $2) $$(LDFLAGS)-include $(addsuffix .d, $2) endef Analysis RPM script

Check out his method of building the RPM package, package the source directory directly, and use a RPM SPEC file template to dynamically generate a SPEC document using sed to build:

$cat beegfs_meta/build/make-rpm #! / bin/bash NAME=beegfs-metaSPEC_FILE=$ {NAME} .specsource. /.. / beegfs-versionarch= `uname-m`if [["$arch" = "x86y64"]]; then BUILDARCH= "$arch" elif [["$arch" = ~ 86]] Then BUILDARCH= "i686" else BUILDARCH=$archfiCONCURRENCY=$ {MAKE_CONCURRENCY:-4} export BEEGFS_VERSION_PATH= `pwd` /.. / beegfs-versionset-epushd.. / TOOLS_ROOT= `pwd`popd BUILD= "${TOOLS_ROOT} / build" mkdir-p $BUILD/buildroot/ {BUILD,RPMS,S {RPMS,PECS,OURCES}} rm-f $BUILD/buildroot/SOURCES/*.tgzROOT_DIR=$ {ROOT_DIR:- `(cd.. /.. Pwd) `} BEEGFS_COMMON_PACKAGE_PATH=$ {BEEGFS_COMMON_PACKAGE_PATH:- `readlink-f.. /.. / beegfs_common_ package`} set + e # test if redhat-rpm-config is installed. If so, we must not specify#% debug_package in the spec file If not installed we need to define it# in order to strip binaries and to build a debug packagerpm-qa redhat-rpm-config | grep redhat-rpm-configNEED_DEBUG_DEFINE=$?set-epushd $TOOLS_ROOTtar czf $BUILD/buildroot/SOURCES/$ {NAME}-${BEEGFS_VERSION} .tgz-- exclude=buildroot/* * cd $BUILDsed-e "s#%BEEGFS_COMMON_PACKAGE_PATH%#$BEEGFS_COMMON_PACKAGE_PATH#g"\-e "s/%NAME%/$NAME/g" \-e "s/%BEEGFS_VERSION%/$BEEGFS_VERSION/g"\-e "s/%BUILDARCH%/$BUILDARCH/g"\-e "s/%MAKE_CONCURRENCY%/$CONCURRENCY/g"\ -e "s/%NEED_DEBUG_DEFINE%/$NEED_DEBUG_DEFINE/g"\ ${SPEC_FILE} .in > ${SPEC_FILE} rpmbuild-- clean-bb ${SPEC_FILE}-- define "_ topdir $BUILD/buildroot/"-D "ROOT_DIR $ROOT_DIR" popdrm-fr / var/tmp/$ {NAME}-root/rm-f / var/tmp/rpm-tmp.* analyze RPM configuration

Check the parameters referenced in SPEC to formalize the result of the replacement of the above script:

$cat beegfs_meta/build/beegfs-meta.spec%define buildarch x86_64%define BEEGFS_COMMON_PACKAGE_PATH / root/beegfs-v6/fhgfs_common_package%define BEEGFS_VERSION% VER%-%RELEASE_STR%%define MAKE_CONCURRENCY 4%define NEED_DEBUG_DEFINE 0%define BEEGFS_VERSION 19.4-git17%define VER% (echo'% {BEEGFS_VERSION}'| cut-d-- f 1)% define BEEGFS_RELEASE_STR% (echo'% {BEEGFS_VERSION}- '| cut-d-- f 2)% define EPOCH% (echo'% {VER}'| cut-d. -f 1)...% buildcd buildmake\ root-dir=% {ROOT_DIR}\ BEEGFS_VERSION=% {BEEGFS_VERSION}\-j% {MAKE_CONCURRENCY}... $grep-rHn root-dir beegfs_meta beegfs_meta/build/Makefile:8:include $(or $(root-dir)) .. /..) / build/Makefilebeegfs_meta/build/beegfs-meta.spec.in:74: root-dir=% {ROOT_DIR}\ beegfs_meta/build/beegfs-meta.spec:74: root-dir=% {ROOT_DIR}\ officially start compilation

Compile the dependent library first:

$make-j$ (nproc)-C beegfs_thirdparty/build$ make-j$ (nproc)-C beegfs_opentk_lib/build$ make-j$ (nproc)-C beegfs_common/build

Compile the required modules as needed:

$make-j$ (nproc)-C beegfs_meta/build clean# make-j$ (nproc)-C beegfs_meta/build BEEGFS_DEBUG=1$ make-j$ (nproc)-C beegfs_meta/ build [ver] BEEGFS_VERSION= "19.5-git9" BEEGFS_VERSION_CODE=18023689make: Entering directory `/ root/beegfs-v6/fhgfs_meta/build' [CXX].. / source/app/App.cpp.o [CXX].. / source/components/DatagramListener.cpp.o [CXX ].. / source/app/config/Config.cpp.o... [CXX].. / source/toolkit/BuddyCommTk.cpp.o [CXX].. / source/toolkit/StorageTkEx.cpp.o [CXX].. / source/toolkit/XAttrTk.cpp.o [LD] beegfs-metamake: Leaving directory `/ root/beegfs-v6/fhgfs_meta/build'$ file / root/beegfs-v6/beegfs_meta/build/beegfs-meta/root/beegfs-v6 / beegfs_meta/build/beegfs-meta: ELF 64-bit LSB executable X86-64, version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID [sha1] = be90bbf04db11b7dcf46d29240b7cb20ab676cf5, not stripped

You can also compile the Debug version, but note that the previously dependent libraries must also be compiled to the Debug version, otherwise the runtime will crash directly:

$make-j$ (nproc)-C beegfs_meta/build BEEGFS_DEBUG= 1 [ver] BEEGFS_VERSION= "19.5-git9" BEEGFS_VERSION_CODE=18023689make: Entering directory `/ root/beegfs-v6/fhgfs_meta/build'make: Nothing to be done for `all'.make: Leaving directory` / root/beegfs-v6/fhgfs_meta/build' [root@sacd02 beegfs-v6] # make-j$ (nproc)-C beegfs_meta/build rpm [VER] BEEGFS_VERSION= "19.5-git9" BEEGFS_VERSION_CODE=18023689make: Entering directory `/ root/beegfs-v6/fhgfs_meta/build'./make-rpm~/beegfs-v6/fhgfs_meta ~ / beegfs-v6/fhgfs_meta/build~/beegfs-v6/fhgfs_meta/buildredhat-rpm-config-9.1.0-87.el7.centos.noarch~/beegfs-v6/fhgfs_meta ~ / beegfs-v6/fhgfs_meta/buildExecuting (% prep): / bin/sh-e / var/tmp/rpm-tmp.0aowao+ umask 022 + cd / root / beegfs-v6/fhgfs_meta/build/buildroot//BUILD+ cd / root/beegfs-v6/fhgfs_meta/build/buildroot/BUILD+ rm-rf beegfs-meta-19.5+ / usr/bin/mkdir-p beegfs-meta-19.5+ cd beegfs-meta-19.5+ / usr/bin/gzip-dc / root/beegfs-v6/fhgfs_meta/build/buildroot/SOURCES/beegfs-meta-19.5-git9.tgz+ / usr/bin/tar-xvvf-drwxr-xr-x root/root 0 2019-05-09 10:32 build/-rw-r--r-- root/root 482 2019-05-08 17:43 build/Makefile-rw-r--r-- root/root 3994 2019-05-08 17:43 build/beegfs-meta.spec.in-rw-r--r-- root/root 1992019-05-08 17:43 build/config.cpackdrwxr-xr-x root/root 0 2019-05-08 17: 43 build/debian/-rw-r--r-- root/root 2019-05-08 17:43 build/debian/changelog.in-rw-r--r-- root/root 2 2019-05-08 17:43 build/debian/compat...-rw-r--r-- root/root 27079 2019-05-08 22:43 source/toolkit/BuddyCommTk.cpp.d-rw-r--r-- root/root 26516 2019-05- 08 22:43 source/toolkit/XAttrTk.cpp.d-rw-r--r-- root/root 2571472 2019-05-08 22:43 source/toolkit/StorageTkEx.cpp.o-rw-r--r-- root/root 2405768 2019-05-08 22:43 source/toolkit/XAttrTk.cpp.o-rw-r--r-- root/root 3042288 2019-05-08 22:43 source/toolkit/BuddyCommTk.cpp.o+ STATUS=0+'['0-ne 0']'+ / usr/bin/chmod-Rf a+rX Upright wreath gripw Bin/sh w. + exit 0Executing (% build): / bin/sh-e / var/tmp/rpm-tmp.FjeeXr+ umask 022 + cd / root/beegfs-v6/fhgfs_meta/build/buildroot//BUILD+ cd beegfs-meta-19.5+ cd build+ make root-dir=/root/beegfs-v6 BEEGFS_VERSION=19.5-git9-j 4 [VER] BEEGFS_VERSION= "19.5-git9" BEEGFS_VERSION_CODE=18023689make [1]: Entering directory `/ root/beegfs-v6/fhgfs_meta/build/buildroot/ BUILD/beegfs-meta-19.5/build'make [1]: warning:-jN forced in submake: disabling jobserver mode.make [1]: Nothing to be done for `all'.make [1]: Leaving directory `/ root/beegfs-v6/fhgfs_meta/build/buildroot/BUILD/beegfs-meta-19.5/build'+ exit 0Executing (% install): / bin/sh-e / var/tmp/rpm-tmp.OeYWrw+ umask 022 + cd / root/beegfs-v6/fhgfs_meta/build/buildroot / / BUILD+'[/ root/beegfs-v6/fhgfs_meta/build/buildroot/BUILDROOT/beegfs-meta-19.5-git9el7.x86_64'! ='/']'+ rm-rf / root/beegfs-v6/fhgfs_meta/build/buildroot/BUILDROOT/beegfs-meta-19.5-git9el7.x86_64++ dirname / root/beegfs-v6/fhgfs_meta/build/buildroot/BUILDROOT/beegfs-meta-19.5-git9el7.x86_64+ mkdir-p / root/beegfs- V6 mkdir RPM_BUILD_ROOT mkdir RPM_BUILD_ROOT (/ root/beegfs-v6/fhgfs_meta/build/buildroot/BUILDROOT/beegfs-meta-19.5-git9el7.x86_64) 'mkdir RPM_BUILD_ROOT (/ root/beegfs-v6/fhgfs_meta/build/buildroot/BUILDROOT/beegfs-meta) -19.5-git9el7.x86_64) + mkdir-p / root/beegfs-v6/fhgfs_meta/build/buildroot/BUILDROOT/beegfs-meta-19.5-git9el7.x86_64/etc/beegfs/+ cp-a dist/etc/beegfs-meta.conf / root/beegfs-v6/fhgfs_meta/build/buildroot/BUILDROOT/beegfs-meta-19.5-git9el7.x86_64/etc/beegfs/+ mkdir-p / root/beegfs-v6/fhgfs_meta/build/buildroot/BUILDROOT/beegfs -meta-19.5-git9el7.x86_64/etc/init.d/+ INITSCRIPT=dist/etc/init.d/beegfs-meta.init+ install-D dist/etc/init.d/beegfs-meta.init / root/beegfs-v6/fhgfs_meta/build/buildroot/BUILDROOT/beegfs-meta-19.5-git9el7.x86_64/etc/init.d/beegfs-meta+ install-D-m644 dist/usr/lib/systemd/system/beegfs-meta.service / root/beegfs-v6/fhgfs_meta/ Build/buildroot/BUILDROOT/beegfs-meta-19.5-git9el7.x86_64/usr/lib/systemd/system/beegfs-meta.service+ GENERIC_INITSCRIPT=/root/beegfs-v6/fhgfs_common_package/build/dist/etc/init.d/beegfs-service.init+ cat / root/beegfs-v6/fhgfs_common_package/build/dist/etc/init.d/beegfs-service.init+ install-D beegfs-meta / root/beegfs-v6/fhgfs_meta/build/buildroot/BUILDROOT/beegfs-meta- 19.5Mugit 9el7.x86 64 dist/sbin/beegfs-setup-meta opt dist/etc/default/beegfs-meta dist/etc/default/beegfs-meta / root/beegfs-v6/fhgfs_meta/build/buildroot/BUILDROOT/beegfs-meta-19.5-git9el7.x86_64/etc/default/ Beegfs-meta+ / usr/lib/rpm/find-debuginfo.sh-- strict-build-id-m-run-dwz-- dwz-low-mem-die-limit 10000000-- dwz-max-die-limit 110000000 / root/beegfs-v6/fhgfs_meta/build/buildroot//BUILD/beegfs-meta-19.5extracting debuginfo from / root/beegfs-v6/fhgfs_meta/build/buildroot/BUILDROOT/beegfs-meta-19.5-git9el7.x86_64/opt/beegfs/sbin/beegfs-metadwz: Too few files for multifile optimization/usr/lib/rpm/sepdebugcrcfix: Updated 1 CRC32s 0 CRC32s did match.+ / usr/lib/rpm/check-buildroot+ / usr/lib/rpm/redhat/brp-compress+ / usr/lib/rpm/redhat/brp-strip-static-archive / usr/bin/strip+ / usr/lib/rpm/brp-python-bytecompile / usr/bin/python 1 + / usr/lib/rpm/redhat/brp-python-hardlink+ / usr/lib/rpm/redhat/brp-java-repack-jarsProcessing files: beegfs-meta-19.5-git9el7.x86_64Provides: beegfs-meta = 19 : 19.5-git9el7 beegfs-meta (x86-64) = 19:19.5-git9el7 config (beegfs-meta) = 19:19.5-git9el7Requires (interp): / bin/sh / bin/shRequires (rpmlib): rpmlib (CompressedFileNames)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report