Light Display Manager 是一个轻量级的跨桌面环境的 Display Manager, 可以支持多种显示技术,如 X11, Mir, Wayland.

Build

Dependencies

  • 开发包依赖

    • libpam0g-dev
    • libgcrypt20-dev
    • libglib2.0-dev
    • libxklavier-dev
  • 构建工具依赖

    • intltool
    • yelp-tools
    • gtk-doc-tools
  • 安装

Lightdm 可执行程序路径 /usr/sbin/lightdm, 日志默认路径 /var/log/lightdm/lightdm.log. 所以构建时可以使用

  • --prefix 指定安装路径 (默认 /usr/local)
  • --localstatedir 指定日志路径 (默认 $prefix/var/log/lightdm)
  • --sysconfdir 指定 lightdm.conf 路径 (默认 $prefix/etc/lightdm)
1
2
3
./autogen.sh --prefix=/usr --localstatedir=/var --sysconfdir=/etc --disable-tests
make -j $JOBS
sudo make install

Graphics Boot-up

flowchart TD
    A["systemd"]
    B["/usr/sbin/lightdm"]
    C["`[Seat:*]
        # Dump core
        xserver-command=X -core`"]
    D["`X
        Symbolic link to Xorg`"]

    A -- lightdm.service --> B -- /usr/share/lightdm/lightdm.conf.d/50-xserver-command.conf --> C --> D

P.S. lightdm --show-config 可以显示与 lightdm 相关的配置

编译内核

  • 配置内核最简单的方法是 make olddefconfig
  • 内核配置保存在 .config
  • 内核源码树里包含命令行修改 .config 的脚本 scripts/config
  • 内核构建依赖 flex, bison 词法分析程序

Ubuntu

  • Environment
configuration version
distro Ubuntu 22.04 Jammy Jellyfish
gcc 11.2.0
original kernel 5.15.0-43-generic
building kernel v6.0
  • Compilation Errors
Errors Need to do
gelf.h: No such file or directory apt install libelf-dev
<openssl/opensslv.h>: No such file or directory apt install libssl-dev
No rule to make target ‘debian/canonical-certs.pem’ scripts/config --disable SYSTEM_TRUSTED_KEYS
No rule to make target ‘debian/canonical-revoked-certs.pem’ scripts/config --disable SYSTEM_REVOCATION_KEYS

Windows Subsytem for Linux

  • .config
1
make KCONFIG_CONFIG=Microsoft/config-wsl
  • Compilation Errors
    这是一个非常常见的依赖问题

    1
    2
    3
    4
    5
    6
    7
    8
      LD      vmlinux.o
    MODPOST vmlinux.symvers
    MODINFO modules.builtin.modinfo
    GEN modules.builtin
    BTF: .tmp_vmlinux.btf: pahole (pahole) is not available
    Failed to generate BTF for vmlinux
    Try to disable CONFIG_DEBUG_INFO_BTF
    make: *** [Makefile:1218: vmlinux] Error 1

安装内核

安装内核包括 4 部分:

  • 安装 vmlinuz, 也就是压缩格式的内核 ELF 镜像 make install
    • make install 最终要么调用用户自定义的安装脚本,要么调用内核源码树里的 install.sh 脚本
  • 安装 modules, make modules_install
  • 制作 initramdisk (或者叫 initramfs) 初始化内存盘,它里面会包含必要的 modules
  • 更新 grub, 以便启动时可以选择新内核

Ubuntu

Windows Subsystem for Linux

1
2
[wsl2]
kernel=C:\\Users\\luc\\bzImage

NOTE: 如果以上两行添加进 /etc/wsl.conf 文件,不会有任何作用, 因为 /etc/wsl.conf 不支持 wsl2 Section

  • 配置完成后,重启 WSL Ubuntu 20.04, 新编译的内核将生效。不要用 wsl --terminate.
1
wsl --shutdown Ubuntu-20.04

《程序员的自我修养–链接,装载与库》这本书是在读研时才看的,印象很深,现在想想这本书讲的都是程序员,尤其是从事系统编程的必备素养。这里我将平时使用的跟编译,链接和构建应用程序及库相关的知识记录下来,希望以后能温故知新。

Read more »

Glossary

  • PoC: Proof of Concept, 概念验证
  • Chisel: tExtended on Scala
  • GDSII: 版图
  • RTL: Register-Transfer Level, RTL 语言包括 SystemVerilog, Verilog, VHDL等
  • FIRRTL: Chisel 的“翻译器”, Chisel -> Verilog
  • shift left: 把验证和调试放在 tape in 阶段
  • GEM5: C Simulator for GPU
  • PPA: Power, Performance, Area, used in deciding how to optimize semiconductor designs
Read more »

LLVM & llvm-project

LLVM 是 Low-Level Virtual Machine 的简写,但事实上它与虚拟机关系不大。我们更熟悉它是一套工具链,包括 clang /'klæŋ/, lld, lldb 等等。接触 LLVM 是因为 Mesa llvmpipe 使用 LLVM, 还有 AMDGPU 和 Radeon 的编译器后端都使用 LLVM IR,所以要编译 Mesa 的 -Dgallium-drivers=llvmpipe,radeonsi 都依赖于 LLVM 的诸多组件, 构建 Linux 内核的 eBPF 程序也依赖 LLVM, 构建 perfetto 也依赖 LLVM。这里主要记录 LLVM 的构建和使用的一些问题。

Read more »

Regular Expressions

GNU Extensions

Shorthand Classes

shorthand equivalence
\w [[:alnum:]_]
\W [^[:alnum:]_]
\s [[:space:]]
\S [^[:space:]]

Word Boundaries

shorthand matches
\b position at a word boundary
\B position not at a word boundary
\< position at the start of a word
\> position at the end of a word
\` (backtick) position at the start of subject string
\' (single quote) position at the end of subject string

Perl Compatiable Regular Expression (PCRE)

grep multiline mode

  • -P: 使用 Perl 正则表达式扩展
  • -z: 让 grep 把输入的行看成是一个多个行的集合,一个整体
  • .*?: 后面的 ? 表示 .*non-greedy 模式匹配,也就是尽可能少(短)的匹配
  • (?s): 让 . 匹配包括 \n 在内的任意字符,也就是所谓的 dot all flag.

rg multiline mode

  • -U, --multiline 使能多行匹配,允许正则表达式里包含 \n (普通模式下不允许),但 -U 并不会改变 . 的语义,所以你仍然需要显式地给 . 指定 (?s) flag

    • rg -U 'struct file_operations .*? = ?\{(?s).*?\.mmap = (?s).*?\};' -tc drivers/gpu
      这个例子找出内核 GPU 驱动中所有重写了 mmap file operation 方法的c文件

Lookarounds: Lookahead, Lookbehind

语法 名称 含义
(?=foo) 正向先行断言 Positive Lookahead 向前(右) 字符串里必须有 foo
(?!foo) 负向先行断言 Negative Lookahead 向前(右) 字符串里不能有 foo
(?<=foo) 正向后行断言 Positive Lookbehind 向后(左) 字符串里必须有 foo
(?<!foo) 负向后行断言 Negative Lookbehind 向后(左) 字符串里不能有 foo
  • 它们只是检查是否匹配,不作为最终匹配结果的一部分,即所谓"断言"
  • 它们可以解决 Non greedy 匹配有时解决不了的问题
  • rg (ripgrep) 默认不支持 lookahead, lookbehind, 需要加 -P--pcre2 选项
0%