Skip to content

build: link with libc++ and libc++abi on Linux and Windows #175

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

Merged
merged 10 commits into from
Jul 1, 2025
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
19 changes: 17 additions & 2 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,31 @@ runs:
server-password: MAVEN_TOKEN

- name: Build
run: mvn package -DskipTests
run: |
if [ "${{ inputs.platform-name }}" == "linux_arm" ]; then
mvn package -DskipTests -Plinux-aarch32
elif [ "${{ inputs.platform-name }}" == "linux_arm64" ]; then
mvn package -DskipTests -Plinux-aarch64
else
mvn package -DskipTests
fi
shell: bash

- name: Test
if: ${{ inputs.platform-name != 'linux_arm' && inputs.platform-name != 'linux_arm64' }}
run: mvn -B jar:jar surefire:test
shell: bash

- name: Deploy
env:
MAVEN_USERNAME: ${{ inputs.maven-username }}
MAVEN_TOKEN: ${{ inputs.maven-password }}
run: mvn deploy -DskipTests
run: |
if [ "${{ inputs.platform-name }}" == "linux_arm" ]; then
mvn deploy -DskipTests -Plinux-aarch32
elif [ "${{ inputs.platform-name }}" == "linux_arm64" ]; then
mvn deploy -DskipTests -Plinux-aarch64
else
mvn deploy -DskipTests
fi
shell: bash
68 changes: 64 additions & 4 deletions .github/actions/prepare-linux/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,74 @@ runs:
sudo apt-get update
sudo apt-get install -y pulseaudio libpulse-dev libasound2-dev libdbus-1-dev libudev-dev libv4l-dev libx11-dev libxcomposite-dev libxrandr-dev libxfixes-dev binutils cmake git locales lsb-release ninja-build pkg-config python3 python3-setuptools rsync unzip wget xz-utils

# More recent LLVM and Clang.
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh ${{ matrix.llvm }} all
# Chromium Clang to be used with the clang toolchain file
#curl -s https://raw.githubusercontent.com/chromium/chromium/main/tools/clang/scripts/update.py | python3 - --output-dir=/opt/clang
# Use a more stable version of Clang
sudo mkdir -p /opt/clang
wget https://commondatastorage.googleapis.com/chromium-browser-clang/Linux_x64/clang-llvmorg-20-init-9764-gb81d8e90-72.tar.xz
sudo tar -xvf clang-llvmorg-20-init-9764-gb81d8e90-72.tar.xz -C /opt/clang

# Required for testing
#pulseaudio --start
sudo apt-get install -y pipewire pipewire-pulse gstreamer1.0-pipewire libspa-0.2-bluetooth libspa-0.2-jack pipewire-audio-client-libraries
systemctl --user daemon-reload
systemctl --user --now enable pipewire{,-pulse}.{socket,service}
shell: bash

- name: Install required packages for arm
if: matrix.platform.name == 'linux_arm'
run: |
sudo apt install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf

sudo dpkg --add-architecture armhf

sudo rm /etc/apt/sources.list

sudo tee -a /etc/apt/sources.list > /dev/null <<EOT
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy main restricted universe multiverse
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricted universe multiverse
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted universe multiverse
EOT

sudo apt-get update

sudo apt install -y \
libpulse-dev:armhf \
libx11-dev:armhf \
libxfixes-dev:armhf \
libxrandr-dev:armhf \
libxcomposite-dev:armhf \
libdbus-1-dev:armhf

# Avoid python3 conflict errors.
sudo apt install -y --no-install-recommends libudev-dev:armhf
shell: bash

- name: Install required packages for arm64
if: matrix.platform.name == 'linux_arm64'
run: |
sudo apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu

sudo dpkg --add-architecture arm64

sudo rm /etc/apt/sources.list

sudo tee -a /etc/apt/sources.list > /dev/null <<EOT
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports jammy main restricted universe multiverse
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricted universe multiverse
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted universe multiverse
EOT

sudo apt-get update

sudo apt install -y \
libpulse-dev:arm64 \
libx11-dev:arm64 \
libxfixes-dev:arm64 \
libxrandr-dev:arm64 \
libxcomposite-dev:arm64 \
libdbus-1-dev:arm64

# Avoid python3 conflict errors.
sudo apt install -y --no-install-recommends libudev-dev:arm64
shell: bash
1 change: 0 additions & 1 deletion .github/actions/prepare-macos/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ runs:
steps:
- name: Install required packages
run: |
brew install ninja
# Required for macos-13
pip install setuptools
# Required for macos-14
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ jobs:
fail-fast: false
matrix:
platform:
- name: linux_arm
runs-on: ubuntu-22.04
- name: linux_arm64
runs-on: ubuntu-22.04
- name: linux_x86-64
runs-on: ubuntu-22.04
java: [17]
llvm: [21]
runs-on: ${{ matrix.platform.runs-on }}
steps:
- name: Checkout code
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ env:

jobs:
prepare-release:
strategy:
matrix:
llvm: [ 21 ]
runs-on: ubuntu-22.04
steps:
- id: prepare
Expand Down Expand Up @@ -100,7 +97,6 @@ jobs:
- name: linux_x86-64
runs-on: ubuntu-22.04
java: [17]
llvm: [21]
runs-on: ${{ matrix.platform.runs-on }}
steps:
- name: Checkout code
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ Maven Central artifacts contain native libraries that can be loaded on the follo
<tr align="center">
<th>Linux</th>
<td>✔</td>
<td>-</td>
<td>-</td>
<td>✔ armeabi-v7a</td>
<td>✔ arm64-v8a</td>
</tr>
<tr align="center">
<th>macOS</th>
Expand Down
7 changes: 4 additions & 3 deletions webrtc-jni/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
</activation>
<properties>
<cmake.clang>-T ClangCL</cmake.clang>
<cmake.toolchain.file>toolchain/x86_64-windows-clang.cmake</cmake.toolchain.file>
</properties>
</profile>
<profile>
Expand All @@ -165,7 +166,7 @@
</os>
</activation>
<properties>
<cmake.toolchain.file>toolchain/x86_64-linux-gnu.cmake</cmake.toolchain.file>
<cmake.toolchain.file>toolchain/x86_64-linux-clang.cmake</cmake.toolchain.file>
</properties>
</profile>
<profile>
Expand All @@ -177,7 +178,7 @@
</os>
</activation>
<properties>
<cmake.toolchain.file>toolchain/aarch32-linux-gnu.cmake</cmake.toolchain.file>
<cmake.toolchain.file>toolchain/aarch32-linux-clang.cmake</cmake.toolchain.file>
</properties>
</profile>
<profile>
Expand All @@ -189,7 +190,7 @@
</os>
</activation>
<properties>
<cmake.toolchain.file>toolchain/aarch64-linux-gnu.cmake</cmake.toolchain.file>
<cmake.toolchain.file>toolchain/aarch64-linux-clang.cmake</cmake.toolchain.file>
</properties>
</profile>
</profiles>
Expand Down
12 changes: 9 additions & 3 deletions webrtc-jni/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,18 @@ if(APPLE)
set_source_files_properties(${SOURCES} PROPERTIES COMPILE_FLAGS "-x objective-c++")
target_link_libraries(${PROJECT_NAME} "-framework Foundation" "-framework AVFoundation" "-framework CoreMedia" "-framework CoreAudio" "-framework IOKit")
elseif(LINUX)
target_link_libraries(${PROJECT_NAME} -static-libgcc -static-libstdc++ pulse udev)
if(NOT TARGET_CPU MATCHES "^arm")
set(CXX_LIBS "-static-libgcc -stdlib=libc++ -lc++ -lc++abi")
else()
set(CXX_LIBS "-static-libgcc")
endif()

target_link_libraries(${PROJECT_NAME} ${CXX_LIBS} pulse udev)
elseif(WIN32)
target_link_libraries(${PROJECT_NAME} dwmapi.lib mf.lib mfreadwrite.lib mfplat.lib mfuuid.lib shcore.lib)
target_link_libraries(${PROJECT_NAME} c++.lib msvcprt.lib dwmapi.lib mf.lib mfreadwrite.lib mfplat.lib mfuuid.lib shcore.lib)
endif()

install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT Runtime
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT Runtime
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,7 @@ target_include_directories(${PROJECT_NAME}
include/jni
include/jni/${JNI_PLATFORM}
)

if(LINUX OR WIN32)
target_link_libraries(${PROJECT_NAME} PRIVATE webrtc)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "JavaThreadEnv.h"
#include "JavaWrappedException.h"

#include <exception>
#include <ios>

bool ExceptionCheck(JNIEnv * env)
Expand Down
Loading