The build fails due to hard coded GCC versions in the code. eg:
brew install gcc49 installs binary x86_64-apple-darwin16.0.0-c++-4.9 on MacOS Sierra but the code has x86_64-apple-darwin15.4.0-c++-4.9 and is hard coded in resources/macos/patches/ungoogled-macos/fix-libcxx-archive-build-script.patch and buildlib/macos.py
The versions can be put into a config file and can be parsed using ConfigParser but not sure how to include that version in the patch file(resources/macos/patches/ungoogled-macos/fix-libcxx-archive-build-script.patch)
Yeah someone reported that earlier and they closed it themselves for reasons I'm not sure...
Instead of hardcoding the path in a config file, I want to implemenet a function in MacOSBuilder that can auto-detect the path to Homebrew's GCC. However, I don't know enough about Homebrew to figure out the best way to detect the GCC path.
I am planning on using #69 to solve the problem of a version-dependent path to the compiler in the patch file.
Adding help wanted label so someone can help out with Homebrew.
I'm no expert, but this does the trick under Python 3.5 on MacOS Sierra:
@static_method
def get_homebrew_gcc_bin():
brew_list_gcc = subprocess.Popen(['brew', 'list', 'gcc'],
stdout=subprocess.PIPE)
grep_gcc_path = subprocess.Popen(['grep', 'bin/x86_64'],
stdin=brew_list_gcc.stdout,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = grep_gcc_path.communicate()
result = out.split(b'\n')[0]
if not result:
raise OSError("Is gcc properly installed? Please check the output of \"brew list gcc\"")
return result
In [34]: get_homebrew_gcc_bin()
Out[34]:
b'/usr/local/Cellar/gcc/6.2.0/bin/x86_64-apple-darwin15.6.0-c++-6'
I did some research, and this gist gives us some helpful hints.
@dangom: Is gcc-4.9 or something similar already in your PATH?
$(brew --prefix)/bin?@Eloston
_Is gcc-4.9 or something similar already in your PATH?_
No, it isn't.
_If not, is there one in $(brew --prefix)/bin?_
No, I only have 6.2 on brew, and it isn't symlinked to /usr/local/bin/. My PATH still points to /usr/bin/gcc.
I haven't built Chromium myself yet.
The dummy function above will always return the oldest available brew install - since the folders are listed in alphabetical order. Should the oldest be 4.9.0, then that's what we get.
We can force search for gcc-4.9:
grep_gcc_path = subprocess.Popen(['grep', 'bin/x86_64.*c++-4.9'],
Massaging the output of the function gives us the directory name we need:
import functools as ftools
tmp = get_homebrew_gcc_bin()
gcc_path = b'/' + ftools.reduce(lambda a,b: a + b'/' + b, tmp.split(b'/')[1:-1])
In [128]: gcc_path
Out[128]:
b'/usr/local/Cellar/gcc/6.2.0/bin'
Prepending this to the PATH, as you suggested in #69, should do the trick without having to symlink all gcc binaries or overwrite user defaults.
Again, I'm not an expert. Would a fix for the include and lib directories also be necessary for the build?
No, it isn't.
So that means gcc-6.2 is not in your PATH? That's interesting.
No, I only have 6.2 on brew, and it isn't symlinked to /usr/local/bin/. My PATH still points to /usr/bin/gcc.
So brew --prefix returns /usr/local? Well I guess that makes sense.
Prepending this to the PATH, as you suggested in #69, should do the trick without having to symlink all gcc binaries or overwrite user defaults.
I'm confused. Are you saying that there's a gcc-6.2 in /usr/local/Cellar/gcc/6.2.0/bin? If not, then it doesn't help to append that to the PATH. Also, #69 isn't suggesting prepending system directories to PATH, unless I'm misinterpreting what you're saying.
Do you know if there's a way to get a list of installed GCC versions? Is there a function to get information about a specific GCC version that's installed?
_Are you saying that there's a gcc-6.2 in /usr/local/Cellar/gcc/6.2.0/bin?_
Yes. These are the files in said directory:
/usr/local/Cellar/gcc/6.2.0/bin/x86_64-apple-darwin15.6.0-c++-6
/usr/local/Cellar/gcc/6.2.0/bin/x86_64-apple-darwin15.6.0-g++-6
/usr/local/Cellar/gcc/6.2.0/bin/x86_64-apple-darwin15.6.0-gcc-6
/usr/local/Cellar/gcc/6.2.0/bin/x86_64-apple-darwin15.6.0-gcc-6.2.0
/usr/local/Cellar/gcc/6.2.0/bin/x86_64-apple-darwin15.6.0-gcc-ar-6
/usr/local/Cellar/gcc/6.2.0/bin/x86_64-apple-darwin15.6.0-gcc-nm-6
/usr/local/Cellar/gcc/6.2.0/bin/x86_64-apple-darwin15.6.0-gcc-ranlib-6
/usr/local/Cellar/gcc/6.2.0/bin/x86_64-apple-darwin15.6.0-gfortran-6
$ /usr/local/Cellar/gcc/6.2.0/bin/x86_64-apple-darwin15.6.0-gcc-6 --version
x86_64-apple-darwin15.6.0-gcc-6 (Homebrew gcc 6.2.0) 6.2.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I guess I must have misunderstood #69 then. My bad.
Create a directory build/path_overrides that contains files to override PATH commands. ...
For Python, /usr/bin/python will have to be changed to point to the Python command in path_overrides.
Your idea is to have a directory with symlinks to the correct binaries? And prepend this build/path_overrides to the PATH?
I don't know how to get a list of installed GCC versions apart from brew list | grep gcc. Or looping through the $PATH and seeing what's in there.
What information about GCC versions are you interested in?
Yes. These are the files in said directory:
But there's no file called gcc-6.2 in that directory. The problem is that those file names contain other values that are more likely to change depending on the version being built. gcc-6.2 is supposed to match against the latest GCC in the 6.2.x series. That's why I was hoping that there was a file named gcc-6.2 in /usr/local/bin so we wouldn't have to assume certain patterns in the actual GCC path.
The reason I want a command like that is so I don't have to use #69 to solve this problem.
Well I did some very quick research and came across this bug report. It looks like there is a way to list gcc versions, and a way to create symlinks in /usr/local/bin. Could you try running brew link gcc and seeing if that adds a command called gcc-6.2 to your PATH?
Not quite gcc-6.2, but brew link gcc adds gcc-6 to my path.
$ which gcc-6
/usr/local/bin/gcc-6
$ gcc-6 --version
gcc-6 (Homebrew gcc 6.2.0) 6.2.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Oh cool. I think that will work instead of using #69.
Would you mind testing to see if GCC 4.9 from Homebrew is available as gcc-4.9 or something similar?
It is. Takes an awful long time to build though.
brew install homebrew/versions/gcc49
馃嵑 /usr/local/Cellar/gcc49/4.9.3: 1,181 files, 196.4M, built in 62 minutes 48 seconds
$ which gcc-4.9 && gcc-4.9 --version
/usr/local/bin/gcc-4.9
gcc-4.9 (Homebrew gcc49 4.9.3) 4.9.3
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
It is. Takes an awful long time to build though.
Oh cool. Glad to hear it works. I didn't know that Homebrew actually builds the compiler each time; that's interesting.
Hey, I had this problem the first time I was building the project for MacOS. I had to modify the patch file in order to get it to build. I made a pull request based on the conversation here to properly detect the existence of gcc-4.9 and then use the c++-4.9 binary that gcc-4.9 provides when it's installed.
Most helpful comment
Hey, I had this problem the first time I was building the project for MacOS. I had to modify the patch file in order to get it to build. I made a pull request based on the conversation here to properly detect the existence of gcc-4.9 and then use the c++-4.9 binary that gcc-4.9 provides when it's installed.