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

back to autotools build on unix for now #130

Merged
merged 2 commits into from
Sep 7, 2022
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
54 changes: 54 additions & 0 deletions recipe/build-shared.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

set -ex

if [ "$(uname)" == "Linux" ];
then
# protobuf uses PROTOBUF_OPT_FLAG to set the optimization level
# unit test can fail if optmization above 0 are used.
CPPFLAGS="${CPPFLAGS//-O[0-9]/}"
CXXFLAGS="${CXXFLAGS//-O[0-9]/}"
export PROTOBUF_OPT_FLAG="-O2"
# to improve performance, disable checks intended for debugging
CXXFLAGS="$CXXFLAGS -DNDEBUG"
elif [ "$(uname)" == "Darwin" ];
then
# remove pie from LDFLAGS
LDFLAGS="${LDFLAGS//-pie/}"
fi

# required to pick up conda installed zlib
export CPPFLAGS="${CPPFLAGS} -I${PREFIX}/include"
export LDFLAGS="${LDFLAGS} -L${PREFIX}/lib"

# Build configure/Makefile as they are not present.
aclocal
libtoolize
autoconf
autoreconf -i
automake --add-missing

./configure --prefix="${PREFIX}" \
--build=${BUILD} \
--host=${HOST} \
--with-pic \
--with-zlib \
--enable-shared \
CC_FOR_BUILD=${CC} \
CXX_FOR_BUILD=${CXX}

# Skip memory hungry tests
export GTEST_FILTER="-IoTest.LargeOutput"
if [ "${HOST}" == "powerpc64le-conda_cos7-linux-gnu" ]; then
make -j 2
make check -j 2 || (cat src/test-suite.log; exit 1)
else
make -j ${CPU_COUNT}
if [[ "$CONDA_BUILD_CROSS_COMPILATION" != 1 ]]; then
make check -j ${CPU_COUNT} || (cat src/test-suite.log; exit 1)
fi
fi
make install
rm ${PREFIX}/lib/libprotobuf.a
rm ${PREFIX}/lib/libprotobuf-lite.a
rm ${PREFIX}/lib/libprotoc.a
7 changes: 7 additions & 0 deletions recipe/build-static.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -euo pipefail

mkdir -p ${PREFIX}/lib
ls -l ./src/.libs/libproto*.a
cp ./src/.libs/libproto*.a ${PREFIX}/lib/
30 changes: 21 additions & 9 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ source:
folder: third_party/googletest

build:
number: 1
number: 2

outputs:
- name: libprotobuf
script: build-lib.sh # [unix]
script: build-shared.sh # [unix]
# cmake script currently disabled due to compatibility issues with
# existing builds; see #49 for potential solution, or switch with 3.22
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching with 3.22 is not a good idea. We want to be able to switch between cmake and autotools build if the need arises. Therefore #49 is the best way forward.

Copy link
Member Author

@h-vetinari h-vetinari Sep 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see this comment. Upstream already aligned the names and soversions, but it still broke.

I also don't see the benefit of being able to switch back to autotools. It just a large surface for breakage for very little gain AFAICT, especially now that upstream has graduated CMake to first class citizen.

Copy link
Member

@isuruf isuruf Sep 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see this #68 (comment).

I know. Please see my comment on #49 about fixing protobuf_SO_VERSION and other variables.

I also don't see the benefit of being able to switch back to autotools. It just a large surface for breakage for very little gain AFAICT, especially now that upstream has graduated CMake to first class citizen.

AFAICT, CMake was not a first class citizen up-to-now. If that becomes the default installation, that is fine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upstream already aligned the names and soversions, but it still broke.

Yes, it was done by someone without a good understanding of how autotools works. I specifically added a feature to CMake to make it easier to replicate autotools behaviour because of protobuf.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT, CMake was not a first class citizen up-to-now. If that becomes the default installation, that is fine.

That is how I interpret protocolbuffers/protobuf#9596

# script: build-lib.sh # [unix]
script: build-lib.bat # [win]
build:
run_exports:
Expand All @@ -45,8 +48,14 @@ outputs:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- cmake
- ninja
- cmake # [win]
- ninja # [win]
- autoconf # [not win]
- automake # [not win]
- libtool # [not win]
- pkg-config # [not win]
- unzip # [not win]
- make # [not win]
host:
- zlib
run:
Expand All @@ -65,8 +74,8 @@ outputs:
- if exist %LIBRARY_LIB%\{{ each_lib }}.lib exit 1 # [win]
{% endfor %}

# cmake
- test -f ${PREFIX}/lib/cmake/protobuf/protobuf-config.cmake # [unix]
# cmake (disabled on unix currently)
# - test -f ${PREFIX}/lib/cmake/protobuf/protobuf-config.cmake # [unix]
- if not exist %LIBRARY_LIB%\cmake\protobuf\protobuf-config.cmake exit 1 # [win]

# pkgconfig
Expand All @@ -79,14 +88,17 @@ outputs:
- protoc --help

- name: libprotobuf-static
script: build-lib.sh # [unix]
script: build-static.sh # [unix]
# cmake script currently disabled due to compatibility issues with
# existing builds; see #49 for potential solution, or switch with 3.22
# script: build-lib.sh # [unix]
script: build-lib.bat # [win]
requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- cmake
- ninja
- cmake # [win]
- ninja # [win]
host:
- zlib
- {{ pin_subpackage('libprotobuf', exact=True) }}
Expand Down