Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation with musl libc (fixes #164) + make CI cover compilation with musl libc + bump version to 1.6.2 #165

Merged
merged 4 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 55 additions & 3 deletions .github/workflows/linux_and_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ jobs:
clang_repo_suffix:
make: bmake
runs-on: ubuntu-22.04
- cc: musl-gcc
cxx: 'false'
clang_major_version: null
clang_repo_suffix: null
make: bmake
runs-on: ubuntu-22.04
- cc: gcc-11
cxx: g++-11
clang_major_version: null
Expand Down Expand Up @@ -74,6 +80,7 @@ jobs:
sudo apt-get install --yes --no-install-recommends \
bmake \
libncurses-dev \
musl-tools \
pkg-config

- name: Install build dependencies
Expand Down Expand Up @@ -101,6 +108,46 @@ jobs:
- name: Checkout Git branch
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Build musl Ncurses
if: "${{ runner.os == 'Linux' && contains(matrix.cc, 'musl') }}"
run: |-
set -x -o pipefail

sudo apt-get remove --yes libncurses-dev # to be sure to not mix them

wget -q https://invisible-island.net/datafiles/release/ncurses.tar.gz
tar xf ncurses.tar.gz
pushd ncurses-*/
configure_args=(
# Redirect everything to musl
CC=musl-gcc
--prefix=/usr
--includedir=/usr/include/x86_64-linux-musl
--libdir=/usr/lib/x86_64-linux-musl

# Enable things we rely on
--enable-pc-files
--enable-shared
--enable-widec

# Disable things we don't need (to speed up CI)
--disable-static
--without-cxx-binding
--without-manpages
--without-progs
--without-tack
--without-tests
)
./configure "${configure_args[@]}"
make -j$(nproc)
sudo make install
popd
rm -Rf ncurses-*/ ncurses.tar.gz

# Mass-fix "#include <x86_64-linux-musl/foo.h>" to "#include <foo.h>"
grep -RlF "<x86_64-linux-musl/" /usr/include/x86_64-linux-musl/ \
| xargs sudo sed 's,<x86_64-linux-musl/,<,' -i

- name: 'Build'
env:
CC: ${{ matrix.cc }}
Expand All @@ -117,9 +164,14 @@ jobs:
as_needed='-Wl,--as-needed'
fi

# ASan: https://clang.llvm.org/docs/AddressSanitizer.html
# UBSan: https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
sanitizer='-fsanitize=address,undefined -fno-sanitize-recover=all'
# musl-gcc does not seem to support linking with sanitizers
if [[ ${{ matrix.cc }} =~ musl ]]; then
sanitizer=
else
# ASan: https://clang.llvm.org/docs/AddressSanitizer.html
# UBSan: https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
sanitizer='-fsanitize=address,undefined -fno-sanitize-recover=all'
fi

${MAKE} --version 2>/dev/null || true

Expand Down
6 changes: 3 additions & 3 deletions recordings/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
| │ |
| └─────────────────────────────────────────────────────────────────────────────────────> |
| X Thu Jan 1 00:00:00 1970 |
|   https://github.com/tenox7/ttyplot 1.6.1 |
|   https://github.com/tenox7/ttyplot 1.6.2 |
+------------------------------------------------------------------------------------------+

[90x20] Frame 2:
Expand All @@ -43,7 +43,7 @@
| │ XX |
| └─────────────────────────────────────────────────────────────────────────────────────> |
| X last=3.0 min=1.0 max=3.0 avg=2.0 Thu Jan 1 00:00:00 1970 |
|   last=4.0 min=2.0 max=4.0 avg=3.0 https://github.com/tenox7/ttyplot 1.6.1 |
|   last=4.0 min=2.0 max=4.0 avg=3.0 https://github.com/tenox7/ttyplot 1.6.2 |
+------------------------------------------------------------------------------------------+

[90x20] Frame 3:
Expand All @@ -67,6 +67,6 @@
| │ XX |
| └─────────────────────────────────────────────────────────────────────────────────────> |
| X last=3.0 min=1.0 max=3.0 avg=2.0 Thu Jan 1 00:00:00 1970 |
|   last=4.0 min=2.0 max=4.0 avg=3.0 https://github.com/tenox7/ttyplot 1.6.1 |
|   last=4.0 min=2.0 max=4.0 avg=3.0 https://github.com/tenox7/ttyplot 1.6.2 |
+------------------------------------------------------------------------------------------+

2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: ttyplot
version: 1.6.1
version: 1.6.2
summary: realtime plotting utility for terminal/console with data input from stdin
description: |
takes data from standard input / unix pipeline,
Expand Down
6 changes: 6 additions & 0 deletions stresstest.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
// License: Apache 2.0
//

// This is needed for musl libc
#if ! defined(_XOPEN_SOURCE) || (_XOPEN_SOURCE < 500)
#undef _XOPEN_SOURCE // to address warnings about potential re-definition
#define _XOPEN_SOURCE 500
#endif

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
Expand Down
2 changes: 1 addition & 1 deletion ttyplot.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.Dd December 25, 2023
.Dd January 20, 2024
.Dt TTYPLOT 1
.Os
.Sh NAME
Expand Down
12 changes: 9 additions & 3 deletions ttyplot.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@
// ttyplot: a realtime plotting utility for terminal with data input from stdin
// Copyright (c) 2018 by Antoni Sawicki
// Copyright (c) 2019-2023 by Google LLC
// Copyright (c) 2023 by Edgar Bonet
// Copyright (c) 2023 by Sebastian Pipping
// Copyright (c) 2023-2024 by Edgar Bonet
// Copyright (c) 2023-2024 by Sebastian Pipping
// Apache License 2.0
//

// This is needed on macOS to get the ncurses widechar API, and pkg-config fails to
// define it.
#ifdef __APPLE__
#define _XOPEN_SOURCE_EXTENDED
#else
// This is needed for musl libc
#if ! defined(_XOPEN_SOURCE) || (_XOPEN_SOURCE < 500)
#undef _XOPEN_SOURCE // to address warnings about potential re-definition
#define _XOPEN_SOURCE 500
#endif
#endif

#include <assert.h>
Expand Down Expand Up @@ -40,7 +46,7 @@
#define STR(x) STR_(x)
#define VERSION_MAJOR 1
#define VERSION_MINOR 6
#define VERSION_PATCH 1
#define VERSION_PATCH 2
#define VERSION_STR STR(VERSION_MAJOR) "." STR(VERSION_MINOR) "." STR(VERSION_PATCH)

#define T_RARR '>'
Expand Down