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

New recipe: catchaMouse16-v0.1.0 #9151

Merged
merged 23 commits into from
Aug 13, 2024

Conversation

brendanjohnharris
Copy link
Contributor

This pull request contains a new build recipe:

  • Package name: catchaMouse16
  • Version: v0.1.0

@brendanjohnharris brendanjohnharris marked this pull request as draft July 26, 2024 05:28
@brendanjohnharris brendanjohnharris marked this pull request as ready for review July 26, 2024 07:37
C/catchaMouse16/build_tarballs.jl Outdated Show resolved Hide resolved
C/catchaMouse16/build_tarballs.jl Outdated Show resolved Hide resolved
C/catchaMouse16/build_tarballs.jl Outdated Show resolved Hide resolved
C/catchaMouse16/build_tarballs.jl Outdated Show resolved Hide resolved
C/catchaMouse16/build_tarballs.jl Outdated Show resolved Hide resolved
C/catchaMouse16/build_tarballs.jl Outdated Show resolved Hide resolved
@giordano
Copy link
Member

Error on aarch64 darwin with Clang (which is always the preferred compiler on BSD systems) is

[13:14:33] cc -shared -lm -lgsl -lgslcblas -o "libcatchaMouse16.dylib" main.o fft.o stats.o helper_functions.o histcounts.o CO_AddNoise.o CO_AutoCorr.o CO_HistogramAMI.o CO_NonlinearAutocorr.o CO_TranslateShape.o DN_RemovePoints.o FC_LoopLocalSimple.o IN_AutoMutualInfoStats.o PH_Walker.o SC_FluctAnal.o ST_LocalExtrema.o SY_DriftingMean.o SY_SlidingWindow.o
[13:14:33] ld64.lld: error: undefined symbol: __divdc3
[13:14:33] >>> referenced by helper_functions.c:152
[13:14:33] >>>               helper_functions.o:(symbol _Cdivcc+0x0)
[13:14:33] clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

Sketch of a solution:

# Linking FFMPEG requires the function `__divdc3`, which is implemented in
# `libclang_rt.osx.a` from LLVM compiler-rt.
FLAGS+=(-DCMAKE_SHARED_LINKER_FLAGS="-L${libdir}/darwin -lclang_rt.osx"
-DCMAKE_EXE_LINKER_FLAGS="-L${libdir}/darwin -lclang_rt.osx"
)

# We need libclang_rt.osx.a for linking FFMPEG, because this library provides the
# implementation of `__divdc3`.
BuildDependency(PackageSpec(name="LLVMCompilerRT_jll", uuid="4e17d02c-6bf5-513e-be62-445f41c75a11", version=llvm_version);
platforms=[Platform("aarch64", "macos")]),

@brendanjohnharris
Copy link
Contributor Author

Thanks so much 😊

Error on aarch64 darwin with Clang (which is always the preferred compiler on BSD systems) is

[13:14:33] cc -shared -lm -lgsl -lgslcblas -o "libcatchaMouse16.dylib" main.o fft.o stats.o helper_functions.o histcounts.o CO_AddNoise.o CO_AutoCorr.o CO_HistogramAMI.o CO_NonlinearAutocorr.o CO_TranslateShape.o DN_RemovePoints.o FC_LoopLocalSimple.o IN_AutoMutualInfoStats.o PH_Walker.o SC_FluctAnal.o ST_LocalExtrema.o SY_DriftingMean.o SY_SlidingWindow.o
[13:14:33] ld64.lld: error: undefined symbol: __divdc3
[13:14:33] >>> referenced by helper_functions.c:152
[13:14:33] >>>               helper_functions.o:(symbol _Cdivcc+0x0)
[13:14:33] clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

Sketch of a solution:

# Linking FFMPEG requires the function `__divdc3`, which is implemented in
# `libclang_rt.osx.a` from LLVM compiler-rt.
FLAGS+=(-DCMAKE_SHARED_LINKER_FLAGS="-L${libdir}/darwin -lclang_rt.osx"
-DCMAKE_EXE_LINKER_FLAGS="-L${libdir}/darwin -lclang_rt.osx"
)

# We need libclang_rt.osx.a for linking FFMPEG, because this library provides the
# implementation of `__divdc3`.
BuildDependency(PackageSpec(name="LLVMCompilerRT_jll", uuid="4e17d02c-6bf5-513e-be62-445f41c75a11", version=llvm_version);
platforms=[Platform("aarch64", "macos")]),

.PHONY: all;
all: ${TARGET_LIB}
$(TARGET_LIB): $(OBJS)
$(CC) ${LDFLAGS} -o $@ $^
Copy link
Member

Choose a reason for hiding this comment

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

Linking order is important, see for example https://wiki.gentoo.org/wiki/Project:Quality_Assurance/As-needed#Importance_of_linking_order (this may fix the issue on Windows):

Suggested change
$(CC) ${LDFLAGS} -o $@ $^
$(CC) -o $@ $^ $(LDFLAGS)

Comment on lines 32 to 35
clean:-${RM} ${TARGET_LIB} ${OBJS} $(SRCS:.c=.d)
.PHONY: install
install:
install -Dvm 755 "./lib${SRC_NAME}.$(dlext)" "$(libdir)/lib$(SRC_NAME).$(dlext)"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
clean:-${RM} ${TARGET_LIB} ${OBJS} $(SRCS:.c=.d)
.PHONY: install
install:
install -Dvm 755 "./lib${SRC_NAME}.$(dlext)" "$(libdir)/lib$(SRC_NAME).$(dlext)"
clean:-$(RM) $(TARGET_LIB) $(OBJS) $(SRCS:.c=.d)
.PHONY: install
install:
install -Dvm 755 "./lib$(SRC_NAME).$(dlext)" "$(libdir)/lib$(SRC_NAME).$(dlext)"

Comment on lines 38 to 39
cd $WORKSPACE/srcdir
cd catchaMouse16/C/src/
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
cd $WORKSPACE/srcdir
cd catchaMouse16/C/src/
cd ${WORKSPACE}/srcdir/catchaMouse16/C/src/

RM = rm -f
TARGET_LIB = "lib$(SRC_NAME).$(dlext)"

SRCS = main.c fft.c stats.c helper_functions.c histcounts.c CO_AddNoise.c CO_AutoCorr.c CO_HistogramAMI.c CO_NonlinearAutocorr.c CO_TranslateShape.c DN_RemovePoints.c FC_LoopLocalSimple.c IN_AutoMutualInfoStats.c PH_Walker.c SC_FluctAnal.c ST_LocalExtrema.c SY_DriftingMean.c SY_SlidingWindow.c
Copy link
Member

Choose a reason for hiding this comment

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

Maybe do https://github.com/DynamicsAndNeuralSystems/catchaMouse16/blob/56ad41b669a750df3be60d008010c8a84a5cf4bd/C/Makefile#L18 instead of listing the files manually? This isn't very sustainable if the source code upstream changes.

@brendanjohnharris
Copy link
Contributor Author

Thanks for your help, will pick this up again in the morning :)

@giordano
Copy link
Member

Uhm https://buildkite.com/julialang/yggdrasil/builds/12165#01910162-a083-4498-8f3f-aa33363f4411/674-871

[02:07:40] error: /opt/aarch64-apple-darwin20/bin/aarch64-apple-darwin20-install_name_tool: changing install names or rpaths can't be redone for: lib/libcatchaMouse16.dylib (for architecture arm64) because larger updated load commands do not fit (the program must be relinked, and you may need to use -headerpad or -headerpad_max_install_names)
[02:07:40] error: /opt/aarch64-apple-darwin20/bin/aarch64-apple-darwin20-install_name_tool: changing install names or rpaths can't be redone for: lib/libcatchaMouse16.dylib (for architecture arm64) because larger updated load commands do not fit (the program must be relinked, and you may need to use -headerpad or -headerpad_max_install_names)

@giordano
Copy link
Member

It doesn't seem to be enough, also, we have the same on x86_64 darwin too.

@brendanjohnharris
Copy link
Contributor Author

@giordano should be ok now, I think; appears to build successfully on all platforms

@giordano giordano merged commit 809e483 into JuliaPackaging:master Aug 13, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants