-
Notifications
You must be signed in to change notification settings - Fork 21
Update Makefile.pdlibbuilder for Apple Silicon #74
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
base: master
Are you sure you want to change the base?
Conversation
umlaeute
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think a better approach would be to just add whatever paths are available.
e.g.
cpp.flags := -DUNIX -DMACOSX $(patsubst %,-I%,$(wildcard /sw/include /opt/homebrew/include))
c.ldflags := -undefined suppress -flat_namespace -bundle $(patsubst %,-L%,$(wildcard /opt/homebrew/lib))
cxx.ldflags := -undefined suppress -flat_namespace -bundle $(patsubst %,-L%,$(wildcard /opt/homebrew/lib))
also note that according to the GNU make documentation, the -L flags should go into LDFLAGS rather than LDLIBS
|
Thank for those advices, if I want to change this pull request, how do I proceed? I see two options: 1° Closing this Pull Request and create another one |
|
In your case I would just amend the commit and force push it |
do you need help with that? |
Yes, I tried git commit --amend, but this is not happening good, it seems I have to be a contributor to do it. |
|
you have to amend the commit on your local install, then push to your github fork https://github.com/patricecolet on the same branch |
|
Okay thank you, I've finally made the correction in patch-1 branch with my web browser. |
Apple Silicon homebrew files location is /opt/homebrew ref: https://docs.brew.sh/Installation
|
i've squashed to two commits into a single one and force pushed them to your branch ... |
|
Being unable to test this pr in practice, I do have question about it. The pr introduces homebrew search paths as an update for Apple silicon. Equivalent paths for macOS Intel were never specified in Makefile.pdlibbuilder, neither in the pull request. Probably because pd externals did not need those paths by default. So my main question for @patricecolet is: how are homebrew paths more important for externals built on Apple silicon than on MacOs Intel? By the way Pd's configure.ac does specify the "old" homebrew paths: |
|
As far as I can tell from the CI builds of purest_json, The explicit paths to curl are necessary, because the CI machine has curl already installed. |
|
I guess this is well explained here: https://apple.stackexchange.com/questions/437618/why-is-homebrew-installed-in-opt-homebrew-on-apple-silicon-macs
|
|
I am unsure about setting the path in the template though, because not everyone will be using Hombrew, others might use MacPorts, or they might want to load custom built dependencies from some other locations. |
|
the fun part about this PR is, that it only uses
that's because |
|
@katjav wrote:
that doesn't mean exactly much.
|
|
Like so often I'm wrong about many things:
|
|
It worked with Homebrew before, since Homebrew installed into My 2 cents: This is a documentation issue. As OTOH This doesn't add any major overhead to pd-lib-builder... as opposed to my #69... |
|
For building externals on Apple Silicon with homebrew we should use |
Yes, which you as an external author can put in your Makefile... # Makefile for foo
lib.name = foo
class.sources = foo.c
datafiles = foo-help.pd README.md LICENSE.txt
# include paths for homebrew
define forDarwin
cflags += -I/opt/homebrew/include
ldflgs += -L/opt/homebrew/lib
endef
PDLIBBUILDER_DIR=.
include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder |
|
Regarding pkg-config: definitely use it if the libs you are using support it. Something like the following if linking to "libbar": # Makefile for foo which links to libbar
lib.name = foo
class.sources = foo.c
datafiles = foo-help.pd README.md LICENSE.txt
# get paths & libs for libbar via pkg-config
define forDarwin
cflags += $(shell pkg-config --cflags bar)
ldflgs += $(shell pkg-config --libs bar)
endef
PDLIBBUILDER_DIR=.
include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilderFor instance, on my system pkg-config reports the following for libsdl2: % pkg-config --cflags sdl2
-D_THREAD_SAFE -I/opt/homebrew/include -I/opt/homebrew/include/SDL2
% pkg-config --libs sdl2
-L/opt/homebrew/lib -lSDL2 |
|
@danomatika suggested: # include paths for homebrew
define forDarwin
cflags += -I/opt/homebrew/include
ldflags += -L/opt/homebrew/lib
endefhonestly that seems backward, as the same stanza is required for each and every external that has any dependencies (beyond Pd) that needs to be compiled for a new mac. but i think this requires a fundamental discussion about what pd-lib-builder actually is: #75 |
|
just a nitpick: define forDarwin
cflags += $(shell pkg-config --cflags bar)
ldflgs += $(shell pkg-config --libs bar)
endefi think this is backward insofar as cflags += $(shell pkg-config --cflags bar)
ldflgs += $(shell pkg-config --libs bar)
define forDarwin
cflags += -mmacosx-version-min=10.9
endef |
non-standard according to which standards? It's obviously the standard for "standard" homebrew installations on macOS/arm64. OTOH, the used compiler and linker does not know about it (that's why the issue is here in the first place), which is arguably a fault on the Also note that homebrew's pd-lib-builder/Makefile.pdlibbuilder Line 511 in e6cff66
why is that? |
to keep my tirade going (but I'll stop soon): why does pd-lib-builder add |
so to conclude: i think the patch in this PR is really a no-brainer (in relation to prior art in pd-lib-builder (regarding fink)). |
|
I guess I should have stayed out of this. I was a bit annoyed that it’s fine to add extra behavior to smooth out build defaults here but not other places. Whatever. As far as “standards” I suppose it’s always the wrong term to use since Pd about 10 different meanings for it.
enohp ym morf tnes
-----------
Dan Wilcox
danomatika.com
robotcowboy.com
… On Dec 6, 2022, at 9:00 AM, umläute ***@***.***> wrote:
to keep my tirade going (but I'll stop soon)
so to conclude: i think the patch in this PR is really a no-brainer (in relation to prior art in pd-lib-builder (regarding fink)).
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
|
As a developer, I would rather not have extra paths added beyond what is already added by the compiler and my own shell paths. I could imagine running into an issue where I want to use a locally compiled lib but then I actually link to one installed on the path, however this is such an edge case as to not actually happen in practice and there are other approaches which mitigate it, ie. linking the static .a directly etc. At this point, I often appreciate having to be explicit about certain things, as we do in other areas, ie. compiling with certain options etc. In all, you are right, this likely doesn't hurt anything. |
|
how about this: add a new variable The user can override this variable to their likings (on the cmdline). If you do not want to have any of these paths, just run If you only want the shiny homebrew/m1 paths, run: this variable should only be set from the cmdline, and not as part of the |
|
This
I've no reason to oppose this proposal, more |
|
A Sorry for throwing too much into this. Merge the PR and lets move on. |
|
Reading a few more times through this issue I find the suggestion to use pkg-config most interesting. In all practical examples I've seen so far, the base homebrew paths are not sufficient so you would still need to define lib-specific homebrew paths in the lib makefile. Adding homebrew paths in Makefile.pdlibbuilder does not seem useful to me therefore. What if Makefile.pdlibbuilder would expose a variable where the lib makefile can just specify dependency name(s) like: and let Makefile.pdlibbuilder use But first question is whether a |
|
About |
honestly i do not see the point of this. as a user you:
so once you have figured this out, what do we gain from adding a single line instead of the slightly more convoluted adding the latter is not exactly rocket science. so I do not really see the advantages of providing another feature that you need to maintain. esp I don't know how it (EDIT: using EDIT the last paragraph has actually already been shown to be correct in #74 (comment) (i should have re-read the thread before posting) |
|
Re:
iirc hans was somehow engaged in Fink (or at least, he had Fink on the radar, as back then it was practically the (usable) package on OSX), so it was somewhat natural to support it out-of-the-box. |
|
Actually, there is another package manager for mac, I forget the name already. My point is that, yes, there are some useful solutions which have set install locations, but I feel that, like building any C/C++ program, if you are using a lib installed to a non-standard (my meaning: /usr/lib or /usr/local/lib), you would specify the header and lib loading location. I don't see this as onerous to potential developers and simplifies maintenance for us if the makefile doesn't need to chase too many platform-specifics beyond the important stuff like possible architectures and Pd install locations. I also don't see a strong need for a pkg-config helper, although it may improve accessibility for some. I feel like documentation about this is probably enough. For instance, I didn't know about IOhannes UPDATE: Actually, there are two other current package managers, pkgsrc and nix, and of course, the historical Fink. UPDATE: OTOH, we can simply set install locations for everything and hope there are no conflicts or people using multiple managers at the same time. :) |
and
Sorry for my pavlov response to |
|
Thinking about this again, I feel it's fine and good to just add |
Apple Silicon homebrew files location is /opt/homebrew ref: https://docs.brew.sh/Installation