RevyOS上的工程软件生态观测 (4): 构建之从入门到放弃 (上):GNU Make 偶尔也有点好用,你们都收到通知了吗?

大家好,我是 PLCT 丁丑小队的一名实习生。这是我们工程软件测试系列帖的第四篇,接续总集篇源内软件篇预编译包篇

从本期开始,我们将进入“需自行构建或魔改”的范畴。这一类别覆盖范围很广,从简单的依赖解析到复杂的源码移植都包含在内。本篇将聚焦于其中最理想的一类情况:软件本身遵循了良好、标准的构建规范(如 CMake, Autotools),其源代码与 RISC-V 架构及现代编译器兼容。在这种情况下,我们的主要工作是正确地管理编译依赖,并遵循标准的构建流程,而无需对软件本身进行侵入式修改。

1. QCad - 2D CAD 系统

QCad 是一款基于 Qt 工具包的 2D 计算机辅助设计软件。RevyOS 源中并未提供该软件,因此需要我们从源码构建。

构建步骤:

  1. 安装构建依赖
    QCad 依赖大量的 Qt5 组件,需要预先安装。

    sudo apt update
    sudo apt install git build-essential qt5-qmake libqt5svg5-dev qtscript5-dev qtxmlpatterns5-dev-tools libqt5xmlpatterns5-dev qttools5-dev
    
  2. 获取源码并配置

    git clone https://github.com/qcad/qcad.git --depth=1
    cd qcad
    

    由于 RevyOS (Debian Trixie) 提供的 Qt 版本为 5.15.15,而 QCad 的构建系统需要一个对应的配置文件,我们需要手动创建它:

    mkdir -p src/3rdparty/qt-labs-qtscriptgenerator-5.15.15
    cat << 'EOF' > src/3rdparty/qt-labs-qtscriptgenerator-5.15.15/qt-labs-qtscriptgenerator-5.15.15.pro
    include( ../../../shared.pri )
    SUBDIRS = ../qt-labs-qtscriptgenerator-5.5.0/qtbindings
    TEMPLATE = subdirs
    EOF
    
  3. 编译
    使用 qmake 生成 Makefile 并开始编译。

    qmake -r CONFIG+=ractivated
    make release -j$(nproc)
    

运行验证:
编译完成后,可执行文件位于 release/qcad-bin。在 Milk-V Pioneer 上运行正常。

详细的测试报告请见:QCad 测试报告

2. ALBERTA - 有限元方法库

ALBERTA 是一个用于自适应有限元计算的 C++ 库。

构建步骤:

  1. 安装构建依赖
    ALBERTA 使用 Autotools 构建系统。

    sudo apt update
    sudo apt install build-essential automake autoconf libtool pkg-config libtirpc-dev
    
  2. 生成构建脚本并配置

    # 假设已获取源码并进入目录
    ./generate-alberta-automakefiles.sh
    autoreconf --force --install
    ./configure
    
  3. 编译与安装

    make -j$(nproc)
    sudo make install
    

运行验证:
安装后,我们可以通过检查其提供的工具来验证安装是否成功。

debian@revyos-lpi4a:~/alberta3-main$ ./add_ons/gmv/2d/alberta2gmv2d --help

  -s, --scalar=DRV
            Load the data-file DRV which must contain a DOF_REAL_VEC
            dumped to disk by `write_dof_real_vec[_xdr]()'.
            This option may be specified multiple times. The DOF_REAL_VECs
            must belong to the most recently specified mesh.
            See `-m' and `-b' above.
  -v, --vector=DRDV
            Load the data-file DRDV which must contain a DOF_REAL_D_VEC
            dumped to disk by `write_dof_real_d_vec[_xdr]()'.
            This option may be specified multiple times. The vector
            must belong to the most recently specified mesh.
            See `-m' and `-b' above.
  -o, --output=FILENAME
            Specify an output file-name. If this option is omitted, then the
            output file-name is "alberta.gmv".
  -p, --path=PATH
            Specify a path prefix for all following data-files. This option
            may be specified multiple times. PATH is supposed to be the
            directory containing all data-files specified by the following
            `-m', `-s' and `-v' options.
  -h, --help
            Print this help.
debian@revyos-lpi4a:~/alberta3-main$ ./add_ons/gmv/1d/alberta2gmv1d

  -s, --scalar=DRV
            Load the data-file DRV which must contain a DOF_REAL_VEC
            dumped to disk by `write_dof_real_vec[_xdr]()'.
            This option may be specified multiple times. The DOF_REAL_VECs
            must belong to the most recently specified mesh.
            See `-m' and `-b' above.
  -v, --vector=DRDV
            Load the data-file DRDV which must contain a DOF_REAL_D_VEC
            dumped to disk by `write_dof_real_d_vec[_xdr]()'.
            This option may be specified multiple times. The vector
            must belong to the most recently specified mesh.
            See `-m' and `-b' above.
  -o, --output=FILENAME
            Specify an output file-name. If this option is omitted, then the
            output file-name is "alberta.gmv".
  -p, --path=PATH
            Specify a path prefix for all following data-files. This option
            may be specified multiple times. PATH is supposed to be the
            directory containing all data-files specified by the following
            `-m', `-s' and `-v' options.
  -h, --help
            Print this help.

程序正常响应,证明其基本功能可用。

详细的测试报告请见:ALBERTA 测试报告

3. Elmer - 多物理场 FEA 软件

Elmer 是一款用于多物理场问题仿真的开源有限元软件。

构建步骤:

  1. 获取源码

    git clone https://github.com/ElmerCSC/elmerfem.git
    cd elmerfem
    
  2. 配置、编译与安装
    Elmer 使用标准的 CMake 构建流程。

    mkdir build && cd build
    cmake ..
    make -j$(nproc)
    sudo make install
    

运行验证:
安装完成后,elmerf90 等工具将被安装到系统中。

debian@revyos-lpi4a:~/elmerfem$ elmerf90 --help
no elmerice
/usr/bin/f95 --help -fallow-argument-mismatch -DCONTIG= -DHAVE_EXECUTECOMMANDLINE -DUSE_ISO_C_BINDINGS -DUSE_ARPACK -O2 -g -fPIC -shared -I/usr/local/share/elmersolver/include -L/usr/local/share/elmersolver/../../lib/elmersolver -shared -lelmersolver

  -std=<standard>          Assume that the input sources are for <standard>.
  --sysroot=<directory>    Use <directory> as the root directory for headers
                           and libraries.
  -B <directory>           Add <directory> to the compiler's search paths.
  -v                       Display the programs invoked by the compiler.
  -###                     Like -v but options quoted and commands not executed.
  -E                       Preprocess only; do not compile, assemble or link.
  -S                       Compile only; do not assemble or link.
  -c                       Compile and assemble, but do not link.
  -o <file>                Place the output into <file>.
  -pie                     Create a dynamically linked position independent
                           executable.
  -shared                  Create a shared library.
  -x <language>            Specify the language of the following input files.
                           Permissible languages include: c c++ assembler none
                           'none' means revert to the default behavior of
                           guessing the language based on the file's extension.

Options starting with -g, -f, -m, -O, -W, or --param are automatically
 passed on to the various sub-processes invoked by f95.  In order to pass
 other options on to these processes the -W<letter> options must be used.

For bug reporting instructions, please see:
<file:///usr/share/doc/gcc-14/README.Bugs>.
debian@revyos-lpi4a:~/elmerfem$ elmerf90 --version
no elmerice
/usr/bin/f95 --version -fallow-argument-mismatch -DCONTIG= -DHAVE_EXECUTECOMMANDLINE -DUSE_ISO_C_BINDINGS -DUSE_ARPACK -O2 -g -fPIC -shared -I/usr/local/share/elmersolver/include -L/usr/local/share/elmersolver/../../lib/elmersolver -shared -lelmersolver


GNU Fortran (Debian 14.2.0-11revyos1) 14.2.0
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

命令返回了正确的版本信息,表明构建和安装成功。

详细的测试报告请见:Elmer 测试报告

4. GetDP - 通用离散问题求解环境

GetDP 是一个用于处理离散问题的通用计算环境。

构建步骤:

  1. 获取源码

    git clone https://gitlab.onelab.info/getdp/getdp.git
    cd getdp
    
  2. 配置与编译
    同样采用标准的 CMake 流程。

    mkdir build && cd build
    cmake ..
    make -j$(nproc)
    

运行验证:
项目自带测试集,是验证构建正确性的绝佳方式。

debian@revyos-lpi4a:~/getdp-git-source/build$ make test
Running tests...
Test project /home/debian/getdp-git-source/build
    Start 1: ../examples/magnet.pro
1/1 Test #1: ../examples/magnet.pro ...........   Passed    0.81 sec

100% tests passed, 0 tests failed out of 1

Total Test time (real) =   0.81 sec

测试通过,证明软件在 RevyOS 上功能正常。

详细的测试报告请见:GetDP 测试报告

5. OOFEM - 通用有限元程序

OOFEM (Object Oriented Finite Element Method) 是一个面向对象的通用有限元程序。

构建步骤:

  1. 安装依赖并获取源码

    sudo apt-get install build-essential xorg-dev git cmake
    wget https://www.oofem.org/oofem/download/oofem-2.5.zip
    unzip oofem-2.5.zip
    cd oofem-2.5
    
  2. 配置与编译

    mkdir build && cd build
    cmake ..
    make -j$(nproc)
    

运行验证:
使用 ctest 运行其内置的测试套件。

99% tests passed, 1 tests failed out of 271

Total Test time (real) = 1717.85 sec

The following tests FAILED:
        144 - test_quasicontinuum3d.in (Failed)
Errors while running CTest
Output from these tests are in: /home/debian/oofem-2.5/build/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.

结果显示,271 个测试中有 270 个通过,通过率 99%。这表明 OOFEM 在 RISC-V 平台上具有非常高的可用性,仅存在个别问题。

详细的测试报告请见:OOFEM 测试报告

6. TOCHNOG - 免费有限元程序

TOCHNOG 是一款历史悠久的免费有限元软件。它的构建系统相对陈旧,需要一些小小的“魔改”。

构建步骤:

  1. 获取源码
    从 SourceForge 下载源码包并解压。

  2. 更新构建系统
    其自带的 configure 脚本无法识别 riscv64 架构。这是一个非常普遍的问题,解决方法是使用 GNU 官方最新的 config.guessconfig.sub 文件替换掉项目中的旧文件。

    # 进入源码目录
    wget -O config.guess https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
    wget -O config.sub   https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
    chmod +x config.guess config.sub
    
  3. 配置、编译与安装
    更新后,即可正常执行 Autotools 流程。

    ./configure
    make
    sudo make install
    

运行验证:
使用自带的示例文件进行测试。

debian@revyos-lpi4a:~/tochnog/tochnog$ cat test/examp1.dat
(Example 1. See manual. )
group_type 0  -materi
group_materi_density 0  1.
group_materi_viscosity 0  1.e-2
group_materi_elasti_compressibility 0  1.e-2
group_materi_memory 0  -updated_without_rotation
group_integration_points 0  -minimal

post_point 1   0.8 0.1
print_filter 0  -post_point_dof -all -velx -vely

control_mesh_refine_globally           3  -h_refinement
control_mesh_refine_globally           4  -h_refinement

control_timestep                      10  0.01 1.
control_timestep_iterations           10  2
(
control_print                        10  -time_current -post_point_dof
)

target_item 0  -post_point_dof 1 -velx
target_value 0   -0.041 0.1
end_data
debian@revyos-lpi4a:~/tochnog/tochnog$ tochnog test/examp1.dat
CPU time: 2 s

程序正常执行并输出了计算时间,验证成功。

详细的测试报告请见:TOCHNOG 测试报告

总结

本期介绍的软件展示了当开源项目遵循标准构建流程时,将其移植到新架构(如 RISC-V)的成本可以非常低。主要工作集中在解决编译依赖上。即使是对于一些使用旧版 Autotools 的项目,通过更新 config.guess 等文件通常也能解决架构识别问题。

下一期,我们将深入探讨那些需要更复杂操作的构建过程,包括手动编译依赖库和对构建系统进行更深入的修改。

欢迎各位复现/吐槽丁丑小队的所有测试结果。
如果有对我们的测试方法/结果有任何建议/问题,欢迎直接在 GitHub 开 issue,或者在论坛 @ 我们、回帖询问。

6 个赞










1 个赞