koreader / koxtoolchain

Build script for various toolchains used by KOReader
59 stars 22 forks source link

on mac (high sierra) #5

Closed cramoisi closed 6 years ago

cramoisi commented 6 years ago
usage: ./gen-tc.sh PLATFORM

Supported platforms:

    kindle
    kindle5
    kindlepw2
    kobo

MacBook:koxtoolchain sebastien$ ./gen-tc.sh kobo
[*] Building CrossTool-NG . . .
grep: /proc/cpuinfo: No such file or directory
expr: syntax error
MacBook:koxtoolchain sebastien$ 

any lead ?

cramoisi commented 6 years ago

I think the grep on mac is BSD and differ a little from the GNU one...

NiLuJe commented 6 years ago

Yup, /proc is a Linux-specific virtual filesystem ;).

NiLuJe commented 6 years ago

Does getconf _NPROCESSORS_ONLN output something sane on macOS?

NiLuJe commented 6 years ago

Also, c.f., https://crosstool-ng.github.io/docs/os-setup/

cramoisi commented 6 years ago
MacBook:~ sebastien$ getconf _NPROCESSORS_ONLN
4
MacBook:~ sebastien$ 

I don't know what i did with my mac between now and 2 months ago but even the emu doesn't compile anymore. The ./kodev release kobo didn't work at all last time I tried so it the reason I tried this (and was more or less aware of the answer :))

cramoisi commented 6 years ago

Also, c.f., https://crosstool-ng.github.io/docs/os-setup/

will test that !

NiLuJe commented 6 years ago

Fixed in my branch ;). (At least this bit, you still have to cross a few fingers nothing else will blow up, I've never tried ct-ng on a macOS host, it's not as bad as a Win32 host, but there may be growing pains ^^).

I'm not quite sure why @houqp went with a Linux-specific solution (I've always been using getconf in my script), but hopefully the new version is extra-hard to break ;).

(I'm guessing virtualization shenanigans?)

cramoisi commented 6 years ago

(not related but mac doesn't really want i use it :

MacBook:koreader sebastien$ ./kodev fetch-thirdparty grep: /proc/1/cgroup: No such file or directory git submodule init

MacBook:koreader sebastien$ ./kodev build

....

HEAD is now at 9b41062... DynASM: Fix warning. [ 37%] No patch step for 'luajit' [ 50%] No update step for 'luajit' [ 62%] No configure step for 'luajit' [ 75%] Performing build step for 'luajit' sed: impossible de lire : No such file or directory make[4]: [luajit-prefix/src/luajit-stamp/luajit-build] Error 2 make[3]: [CMakeFiles/luajit.dir/all] Error 2 make[2]: [all] Error 2 make[1]: [build/x86_64-apple-darwin17.6.0-debug/luajit] Error 2 make: *** [base/build/-debug/luajit] Error 2 Failed to build emulator! Try run with -v for more information. MacBook:koreader sebastien$

NiLuJe commented 6 years ago

Is the emu compilation failing on an actual compiler error, or a GNU-ism?

EDIT: Too late. :D. GNU-ism ;).

I don't exactly remember what homebrew exactly does with the GNU tools, I know you can call them with their g\<name> variant, and autotools should pick them up, but that may not be enough for everything...

cramoisi commented 6 years ago

so I need to remove something ?

NiLuJe commented 6 years ago

Let me check if that sed call is ours or LuaJIT ;).

NiLuJe commented 6 years ago

We handle the sed switch properly on our end, and LuaJIT's sed calls don't use the offending -i flag, so that's strange...

Try with a verbose build?

export VERBOSE=1
export V=1
cramoisi commented 6 years ago

[ 12%] Performing build step for 'luajit' cd /Users/sebastien/koreader/base/thirdparty/luajit/build/x86_64-apple-darwin17.6.0-debug/luajit-prefix/src/luajit && sh -c "sed -i '' -e 's|#CCDEBUG= -g|CCDEBUG= -g|' /Users/sebastien/koreader/base/thirdparty/luajit/build/x86_64-apple-darwin17.6.0-debug/luajit-prefix/src/luajit/src/Makefile && /Library/Developer/CommandLineTools/usr/bin/make -j5" sed: impossible de lire : No such file or directory make[4]: [luajit-prefix/src/luajit-stamp/luajit-build] Error 2 make[3]: [CMakeFiles/luajit.dir/all] Error 2

NiLuJe commented 6 years ago

Right, that one's ours :D.

And it means sed is now gsed, but we detect it as macOS's sed. Joy.

I assume you have gnu-sed installed via homebrew?

cramoisi commented 6 years ago

MacBook:koreader sebastien$ brew install gnu-sed Warning: gnu-sed 4.5 is already installed and up-to-date To reinstall 4.5, run brew reinstall gnu-sed

NiLuJe commented 6 years ago

On my end, you can't call it as sed unless it's installed with the "with-default-names" option, or you added homebrew's gnubin path to your PATH...

Does any of that ring a bell?

cramoisi commented 6 years ago

it's installing. Yep, it rings a bell ; i already gone through all this in february and everything worked fine

==> Reinstalling gnu-sed --with-default-names ==> Downloading https://ftp.gnu.org/gnu/sed/sed-4.5.tar.xz Already downloaded: /Users/sebastien/Library/Caches/Homebrew/gnu-sed-4.5.tar.xz ==> ./configure --prefix=/usr/local/Cellar/gnu-sed/4.5

NiLuJe commented 6 years ago

i.e., which sed, echo $PATH, brew info gnu-sed.

Okay, trouble is: we don't detect gsed that way, so you should NOT install it with --with-default-names ;).

As for ct-ng, it's autotools all the way, so it should detect gsed properly without needing that, too ;).

cramoisi commented 6 years ago

MacBook:koreader sebastien$ which sed /usr/local/bin/sed

/usr/local/opt/gettext/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

gnu-sed: stable 4.5 (bottled) GNU implementation of the famous stream editor https://www.gnu.org/software/sed/ Conflicts with: ssed (because both install share/info/sed.info) /usr/local/Cellar/gnu-sed/4.5 (49 files, 991.8KB) * Built from source on 2018-07-05 at 01:38:09 with: --with-default-names From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/gnu-sed.rb ==> Options --with-default-names Do not prepend 'g' to the binary

NiLuJe commented 6 years ago

Yep, reinstall it without --with-default-names ;).

cramoisi commented 6 years ago

it doesn't give me the choice :)

NiLuJe commented 6 years ago

brew reinstall gnu-sed --without-default-names?

cramoisi commented 6 years ago

MacBook:koreader sebastien$ brew reinstall gnu-sed --without-default-name ==> Reinstalling gnu-sed --with-default-names Warning: gnu-sed: this formula has no --without-default-name option so it will be ignored! ==> Downloading https://ftp.gnu.org/gnu/sed/sed-4.5.tar.xz Already downloaded: /Users/sebastien/Library/Caches/Homebrew/gnu-sed-4.5.tar.xz ==> ./configure --prefix=/usr/local/Cellar/gnu-sed/4.5

NiLuJe commented 6 years ago

Okay, take two: uninstall, then install without any flag? ^^

NiLuJe commented 6 years ago

Wait, it's names, not name (plural)

cramoisi commented 6 years ago

MacBook:koreader sebastien$ brew uninstall gnu-sed Uninstalling /usr/local/Cellar/gnu-sed/4.5... (49 files, 991.8KB) MacBook:koreader sebastien$ brew install gnu-sed ==> Downloading https://homebrew.bintray.com/bottles/gnu-sed-4.5.high_sierra.bottle.tar.gz ######################################################################## 100.0% ==> Pouring gnu-sed-4.5.high_sierra.bottle.tar.gz ==> Caveats The command has been installed with the prefix "g". If you do not want the prefix, install using the "with-default-names" option.

If you need to use these commands with their normal names, you can add a "gnubin" directory to your PATH from your bashrc like: PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"

Additionally, you can access their man pages with normal names if you add the "gnuman" directory to your MANPATH from your bashrc as well: MANPATH="/usr/local/opt/gnu-sed/libexec/gnuman:$MANPATH" ==> Summary 🍺 /usr/local/Cellar/gnu-sed/4.5: 12 files, 529KB MacBook:koreader sebastien$

ok it worked

NiLuJe commented 6 years ago

which sed should now point to /usr/bin/sed, right?

cramoisi commented 6 years ago

Right !

The compilation of the emu is running ; i will check the toolchain tomorrow ; thanks !

cramoisi commented 6 years ago

strange :

[*] create symlink instead of copying files in development mode
cd koreader-emulator--debug/koreader && \
        ln -sf ../../base/build/-debug/* .
[*] install front spec only for the emulator
cd koreader-emulator--debug/koreader/spec && test -e front || \
        ln -sf ../../../../spec ./front
/bin/bash: line 0: cd: koreader-emulator--debug/koreader/spec: No such file or directory
cd koreader-emulator--debug/koreader/spec/front/unit && test -e data || \
        ln -sf ../../test ./data
/bin/bash: line 0: cd: koreader-emulator--debug/koreader/spec/front/unit: No such file or directory
for f in reader.lua setupkoenv.lua frontend resources defaults.lua datastorage.lua l10n tools README.md COPYING; do \
        ln -sf ../../$f koreader-emulator--debug/koreader/; \
    done
[*] Install plugins
cp -R plugins/* koreader-emulator--debug/koreader/plugins/
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file target_file
       cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file ... target_directory
make: *** [all] Error 64
Failed to build emulator! Try run with -v for more information.
NiLuJe commented 6 years ago

That looks like MACHINE being misdetected (as in, not at all). Not at a computer right now, I'll take a look later this afternoon ;).

NiLuJe commented 6 years ago

What is your koreader-emulator-whatever folder actually named?

cramoisi commented 6 years ago

urg, strange : koreader-emulator--debug

cramoisi commented 6 years ago

I can't explain myself why it worked without problem 1 month ago

Frenzie commented 6 years ago

Could it be related to @NiLuJe 's recent bumps?

NiLuJe commented 6 years ago

That vaguely looks like a bsd make issue (it doesn't support the $(shell) semantics, AFAIK, which is why KindleTool's Makefiles jumps through so many shitty hoops).

What's strange is that make is gmake 3.81 on my 10.13.5 system...

NiLuJe commented 6 years ago

And I haven't installed gmake.

What does make --version say on your system?

As well as clang -dumpmachine, on the off-chance it's something much stupider ;).

NiLuJe commented 6 years ago

As for the cp call themselves, https://github.com/koreader/koreader/pull/4055/commits/3f34f19102a296e11174f3424219e45ed52422be might help?

cramoisi commented 6 years ago

MacBook:koreader sebastien$ make --version GNU Make 3.81 Copyright (C) 2006 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.

This program built for i386-apple-darwin11.3.0

NiLuJe commented 6 years ago

What about the rest? ;)