Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.

Error: at least ftruncate or _chsize functions are required to build #523

Closed
izgzhen opened this issue Mar 5, 2018 · 52 comments
Closed

Comments

@izgzhen
Copy link
Collaborator

izgzhen commented Mar 5, 2018

| Run Ghc LinkHs Stage0: _build/stage0/utils/ghc-pkg/Main.o (and 1 more) => inplace/lib/bin/ghc-pkg
/usr/local/bin/ghc -Wall -hisuf hi -osuf o -hcsuf hc -static -hide-all-packages -no-user-package-db '-package-db /home/zhen/repos/ghc/_build/stage0/bootstrapping.conf' '-package-id Cabal-2.1.0.0' '-package-id base-4.10.1.0' '-package-id binary-0.8.5.1' '-package-id bytestring-0.10.8.2' '-package-id containers-0.5.10.2' '-package-id directory-1.3.0.2' '-package-id filepath-1.4.1.2' '-package-id ghc-boot-8.5' '-package-id process-1.6.1.0' '-package-id terminfo-0.4.1.1' '-package-id unix-2.7.2.2' -i -i_build/stage0/utils/ghc-pkg -i_build/stage0/utils/ghc-pkg/build/ghc-pkg/autogen -iutils/ghc-pkg/. -Iincludes -I_build/generated -I_build/stage0/utils/ghc-pkg -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/process-1.6.1.0/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/process-1.6.1.0/dist-install/build/include -I/home/zhen/repos/ghc/libraries/text/include -I/home/zhen/repos/ghc/libraries/text/dist-install/build/include -I/home/zhen/repos/ghc/_build/stage0/libraries/text/include -I/home/zhen/repos/ghc/_build/stage0/libraries/text/dist-install/build/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/directory-1.3.0.2/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/directory-1.3.0.2/dist-install/build/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/unix-2.7.2.2/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/unix-2.7.2.2/dist-install/build/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/time-1.8.0.2/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/time-1.8.0.2/dist-install/build/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/bytestring-0.10.8.2/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/bytestring-0.10.8.2/dist-install/build/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/base-4.10.1.0/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/base-4.10.1.0/dist-install/build/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/integer-gmp-1.0.1.0/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/integer-gmp-1.0.1.0/dist-install/build/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/dist-install/build/include -I_build/generated -optc-I_build/generated -optP-include -optP_build/stage0/utils/ghc-pkg/build/ghc-pkg/autogen/cabal_macros.h -optc-fno-stack-protector -optP-DWITH_TERMINFO -odir _build/stage0/utils/ghc-pkg -hidir _build/stage0/utils/ghc-pkg -stubdir _build/stage0/utils/ghc-pkg -no-auto-link-packages -rtsopts -optc-Werror=unused-but-set-variable -optc-Wno-error=inline _build/stage0/utils/ghc-pkg/Main.o _build/stage0/utils/ghc-pkg/Version.o -o inplace/lib/bin/ghc-pkg -O -H32m -XHaskell2010
_build/stage0/utils/ghc-pkg/Main.o:rpOD_info: error: undefined reference to 'set_curterm'
_build/stage0/utils/ghc-pkg/Main.o:rpOD_info: error: undefined reference to 'set_curterm'
_build/stage0/utils/ghc-pkg/Main.o:rpOD_info: error: undefined reference to 'set_curterm'
_build/stage0/utils/ghc-pkg/Main.o:rpOD_info: error: undefined reference to 'set_curterm'
/home/zhen/repos/ghc/_build/stage0/libraries/terminfo/libHSterminfo-0.4.1.1.a(Base.o):r9qR_info: error: undefined reference to 'tigetnum'
/home/zhen/repos/ghc/_build/stage0/libraries/terminfo/libHSterminfo-0.4.1.1.a(Base.o):r9qS_info: error: undefined reference to 'tigetflag'
/home/zhen/repos/ghc/_build/stage0/libraries/terminfo/libHSterminfo-0.4.1.1.a(Base.o):r9qT_info: error: undefined reference to 'tigetstr'
/home/zhen/repos/ghc/_build/stage0/libraries/terminfo/libHSterminfo-0.4.1.1.a(Base.o):s9Aq_info: error: undefined reference to 'tparm'
/home/zhen/repos/ghc/_build/stage0/libraries/terminfo/libHSterminfo-0.4.1.1.a(Base.o):s9CB_info: error: undefined reference to 'del_curterm'
/home/zhen/repos/ghc/_build/stage0/libraries/terminfo/libHSterminfo-0.4.1.1.a(Base.o):s9CB_info: error: undefined reference to 'setupterm'
/home/zhen/repos/ghc/_build/stage0/libraries/terminfo/libHSterminfo-0.4.1.1.a(Base.o):s9Et_info: error: undefined reference to 'tputs'
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
shakeArgsWith   0.000s    0%                           
Function shake  0.137s    0%                           
Database read   0.092s    0%                           
With database   0.041s    0%                           
Running rules  24.869s   98%  =========================
Total          25.140s  100%                           
Error when running Shake build system:
* inplace/bin/ghc-pkg
* inplace/lib/bin/ghc-pkg
user error (Development.Shake.cmd, system command failed
Command: /usr/local/bin/ghc -Wall -hisuf hi -osuf o -hcsuf hc -static -hide-all-packages -no-user-package-db '-package-db /home/zhen/repos/ghc/_build/stage0/bootstrapping.conf' '-package-id Cabal-2.1.0.0' '-package-id base-4.10.1.0' '-package-id binary-0.8.5.1' '-package-id bytestring-0.10.8.2' '-package-id containers-0.5.10.2' '-package-id directory-1.3.0.2' '-package-id filepath-1.4.1.2' '-package-id ghc-boot-8.5' '-package-id process-1.6.1.0' '-package-id terminfo-0.4.1.1' '-package-id unix-2.7.2.2' -i -i_build/stage0/utils/ghc-pkg -i_build/stage0/utils/ghc-pkg/build/ghc-pkg/autogen -iutils/ghc-pkg/. -Iincludes -I_build/generated -I_build/stage0/utils/ghc-pkg -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/process-1.6.1.0/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/process-1.6.1.0/dist-install/build/include -I/home/zhen/repos/ghc/libraries/text/include -I/home/zhen/repos/ghc/libraries/text/dist-install/build/include -I/home/zhen/repos/ghc/_build/stage0/libraries/text/include -I/home/zhen/repos/ghc/_build/stage0/libraries/text/dist-install/build/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/directory-1.3.0.2/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/directory-1.3.0.2/dist-install/build/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/unix-2.7.2.2/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/unix-2.7.2.2/dist-install/build/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/time-1.8.0.2/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/time-1.8.0.2/dist-install/build/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/bytestring-0.10.8.2/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/bytestring-0.10.8.2/dist-install/build/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/base-4.10.1.0/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/base-4.10.1.0/dist-install/build/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/integer-gmp-1.0.1.0/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/integer-gmp-1.0.1.0/dist-install/build/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/dist-install/build/include -I_build/generated -optc-I_build/generated -optP-include -optP_build/stage0/utils/ghc-pkg/build/ghc-pkg/autogen/cabal_macros.h -optc-fno-stack-protector -optP-DWITH_TERMINFO -odir _build/stage0/utils/ghc-pkg -hidir _build/stage0/utils/ghc-pkg -stubdir _build/stage0/utils/ghc-pkg -no-auto-link-packages -rtsopts -optc-Werror=unused-but-set-variable -optc-Wno-error=inline _build/stage0/utils/ghc-pkg/Main.o _build/stage0/utils/ghc-pkg/Version.o -o inplace/lib/bin/ghc-pkg -O -H32m -XHaskell2010
Exit code: 1
Stderr:
_build/stage0/utils/ghc-pkg/Main.o:rpOD_info: error: undefined reference to 'set_curterm'
_build/stage0/utils/ghc-pkg/Main.o:rpOD_info: error: undefined reference to 'set_curterm'
_build/stage0/utils/ghc-pkg/Main.o:rpOD_info: error: undefined reference to 'set_curterm'
_build/stage0/utils/ghc-pkg/Main.o:rpOD_info: error: undefined reference to 'set_curterm'
/home/zhen/repos/ghc/_build/stage0/libraries/terminfo/libHSterminfo-0.4.1.1.a(Base.o):r9qR_info: error: undefined reference to 'tigetnum'
/home/zhen/repos/ghc/_build/stage0/libraries/terminfo/libHSterminfo-0.4.1.1.a(Base.o):r9qS_info: error: undefined reference to 'tigetflag'
/home/zhen/repos/ghc/_build/stage0/libraries/terminfo/libHSterminfo-0.4.1.1.a(Base.o):r9qT_info: error: undefined reference to 'tigetstr'
/home/zhen/repos/ghc/_build/stage0/libraries/terminfo/libHSterminfo-0.4.1.1.a(Base.o):s9Aq_info: error: undefined reference to 'tparm'
/home/zhen/repos/ghc/_build/stage0/libraries/terminfo/libHSterminfo-0.4.1.1.a(Base.o):s9CB_info: error: undefined reference to 'del_curterm'
/home/zhen/repos/ghc/_build/stage0/libraries/terminfo/libHSterminfo-0.4.1.1.a(Base.o):s9CB_info: error: undefined reference to 'setupterm'
/home/zhen/repos/ghc/_build/stage0/libraries/terminfo/libHSterminfo-0.4.1.1.a(Base.o):s9Et_info: error: undefined reference to 'tputs'
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
)
  • OS: ubuntu 16.04
  • gcc version: 5.4.0
  • host ghc version: 8.2.2
  • compile with: ./build.sh -j --verbose --no-progress --progress-colour=never --progress-info=brief --profile=-
  • hadrian version: 7894c96
  • target ghc: a9f680f
@snowleopard
Copy link
Owner

This looks similar to https://mail.haskell.org/pipermail/ghc-devs/2018-March/015425.html.

Are you sure you've updated submodules?

@izgzhen
Copy link
Collaborator Author

izgzhen commented Mar 6, 2018

Are you sure you've updated submodules?

I supposed "yes", but I tried again from scratch anyway:

| Fix _build/stage1/libraries/integer-gmp/package-data.mk
shakeArgsWith    0.000s    0%                           
Function shake   0.135s    0%                           
Database read    0.036s    0%                           
With database    0.000s    0%                           
Running rules  694.007s   99%  =========================
Total          694.178s  100%                           
Error when running Shake build system:
* _build/stage1/compiler/setup-config
* _build/stage1/compiler/package-data.mk _build/stage1/compiler/setup-config
* _build/stage1/gmp/include/ghc-gmp.h
* libraries/integer-gmp/gmp/config.mk
* libraries/integer-gmp/gmp/config.mk libraries/integer-gmp/integer-gmp.buildinfo
Error, &%> rule failed to produce 2 files (out of 2)
  libraries/integer-gmp/gmp/config.mk - MISSING
  libraries/integer-gmp/integer-gmp.buildinfo - MISSING
CallStack (from HasCallStack):
  error, called at src/Development/Shake/Internal/Rules/Files.hs:209:13 in shake-0.16.3-Gjbjlakw6DJDzoxGYURGp9:Development.Shake.Internal.Rules.Files

again error.

@izgzhen izgzhen changed the title gcc failed in phase Linker libraries/integer-gmp/gmp/config.mk - MISSING Mar 6, 2018
@izgzhen
Copy link
Collaborator Author

izgzhen commented Mar 6, 2018

I guess the above error is related to

hadrian/src/Rules/Gmp.hs

Lines 80 to 82 in 9eef6a7

[gmpBase -/- "config.mk", gmpBuildInfoPath] &%> \_ -> do
dataFile <- pkgDataFile gmpContext
need [dataFile]

@snowleopard
Copy link
Owner

snowleopard commented Mar 6, 2018

@izgzhen Note: this is a different error! Now it is consistent with what we have in CI.

Thanks for recording this: I'm unlikely to have time to look into this during this week, but if anyone would like to fix Hadrian (presumably this failure is caused by some changes in GHC), I'm happy to review a PR.

@izgzhen
Copy link
Collaborator Author

izgzhen commented Mar 6, 2018

this problem seems to be resolved by:

diff --git a/src/Rules/Gmp.hs b/src/Rules/Gmp.hs
index 46fad8a..4dbbfff 100644
--- a/src/Rules/Gmp.hs
+++ b/src/Rules/Gmp.hs
@@ -78,8 +78,7 @@ gmpRules = do
 
     -- This causes integerGmp package to be configured, hence creating the files
     [gmpBase -/- "config.mk", gmpBuildInfoPath] &%> \_ -> do
-        dataFile <- pkgDataFile gmpContext
-        need [dataFile]
+        build $ target gmpContext (Configure $ pkgPath integerGmp) [gmpBuildInfoPath <.> "in"] [gmpBuildInfoPath]
 
     -- Run GMP's configure script
     -- TODO: Get rid of hard-coded @gmp@.

@izgzhen
Copy link
Collaborator Author

izgzhen commented Mar 6, 2018

But there is more problem coming:

 Run Ghc LinkHs Stage1: _build/stage1/libraries/integer-gmp/c/cbits/wrappers.dyn_o (and 5 more) => _build/stage1/libraries/integer-gmp/libHSinteger-gmp-1.0.1.0-ghc8.5.20180304.so
Warning: -rtsopts and -with-rtsopts have no effect with -shared.
    Call hs_init_ghc() from your main() function to set these options.
configure: error: internal error
shakeArgsWith   0.000s    0%                           
Function shake  0.137s    0%                           
Database read   0.301s    0%                           
With database   0.009s    0%                           
Running rules  47.886s   99%  =========================
Total          48.334s  100%                           
Error when running Shake build system:
* _build/stage1/libraries/base/setup-config
* _build/stage1/libraries/base/package-data.mk _build/stage1/libraries/base/setup-config
user error (Development.Shake.cmd, system command failed
Command: _build/stage0/utils/ghc-cabal/ghc-cabal configure libraries/base /home/zhen/repos/ghc/_build/stage1/libraries/base --with-ghc=/home/zhen/repos/ghc/inplace/bin/ghc-stage1 --with-ghc-pkg=/home/zhen/repos/ghc/inplace/bin/ghc-pkg --enable-library-vanilla --enable-library-for-ghci --enable-library-profiling --enable-shared '--configure-option=CFLAGS=-fno-stack-protector -I/home/zhen/repos/ghc/_build/generated' --configure-option=LDFLAGS=-fuse-ld=gold --configure-option=CPPFLAGS=-I_build/generated '--gcc-options=-fno-stack-protector -I/home/zhen/repos/ghc/_build/generated -fuse-ld=gold' --configure-option=--with-cc=/usr/bin/gcc --with-gcc=/usr/bin/gcc --with-ld=/usr/bin/ld.gold --with-ar=/usr/bin/ar --with-alex=/usr/local/bin/alex --with-happy=/usr/local/bin/happy -v0 --configure-option=--quiet --configure-option=--disable-option-checking --flags=integer-gmp
Exit code: 1
Stderr:
configure: error: internal error
)

this internal error msg can be reproduced by running ./configure under ghc/libraries/base.

@chitrak7
Copy link
Contributor

@izgzhen @snowleopard the error was coming because "struct MD5Context" was not found.
I tried to resolve this by removing and recloning the base repository. This resolved the immediate problem but gave rise to multiple new ones.

@snowleopard
Copy link
Owner

I think this is a good (and urgent!) issue for a beginner. Potential GSoC applicants, give it a try!

@chitrak7
Copy link
Contributor

The error is coming due to the inclusion of this line in libraries/base/configure.ac::240.

AC_CHECK_TYPE([struct MD5Context], [], [AC_MSG_ERROR([internal error])], [#include "include/md5.h"]).

But the file "include/md5.h" is present and is containing struct MD5Context. I have seen the earlier implementations. Earlier implementation returned with value "no" but new implementation causes an error.

@snowleopard
Copy link
Owner

@chitrak7 How does the Make build system deal with this? Why does it succeed? Presumably, it calls the configure in base somehow differently?

@chitrak7
Copy link
Contributor

I have been trying to figure it out. There are no recent changes in any of the concerned makefiles, but I believe that we have been doing this step wrong since the start. Just we were not able to detect it as it didn't cause any errors. Can you give any pointers on where to look @snowleopard

@chitrak7
Copy link
Contributor

chitrak7 commented Mar 12, 2018

@snowleopard The make system is somehow copying a few c libraries from ghc/includes to ghc/libraries/base/include. This is because md5.h has some headers files which are not present with it, but are present in ghc/includes. After this, ./configure runs fine. But the problem is still persisting.

@snowleopard
Copy link
Owner

@chitrak7 Aha, that's a very useful piece of information! Can you link to these specific lines in Makefiles?

@chitrak7
Copy link
Contributor

@snowleopard I have not been able to find this in the Makefile. I am deducing this because the file ghc/libraries/base/include/md5.h has a lot of header files such as "HsFFi.h" which are required for configure to compile. These are present in ghc/includes. Hence, some copying must be done.

@chitrak7
Copy link
Contributor

"inplace/bin/ghc-cabal" configure libraries/base dist-install --with-ghc="/home/chitrak/ghc/inplace/bin/ghc-stage1" --with-ghc-pkg="/home/chitrak/ghc/inplace/bin/ghc-pkg" --flags=integer-gmp --disable-library-for-ghci --enable-library-vanilla --enable-library-for-ghci --enable-library-profiling --enable-shared --with-hscolour="/usr/bin/HsColour" --configure-option=CFLAGS="-Wall -fno-stack-protector -Werror=unused-but-set-variable -Wno-error=inline" --configure-option=LDFLAGS=" " --configure-option=CPPFLAGS=" " --gcc-options="-Wall -fno-stack-protector -Werror=unused-but-set-variable -Wno-error=inline " --with-gcc="gcc" --with-ld="ld.gold" --with-ar="ar" --with-alex="/usr/bin/alex" --with-happy="/usr/bin/happy"
@snowleopard the configure command used for base.

@chitrak7
Copy link
Contributor

_build/stage0/utils/ghc-cabal/ghc-cabal configure libraries/base /home/chitrak/ghc/_build/stage1/libraries/base --with-ghc=/home/chitrak/ghc/inplace/bin/ghc-stage1 --with-ghc-pkg=/home/chitrak/ghc/inplace/bin/ghc-pkg --enable-library-vanilla --enable-library-for-ghci --enable-library-profiling --enable-shared '--configure-option=CFLAGS=-fno-stack-protector -I/home/chitrak/ghc/_build/generated' --configure-option=LDFLAGS=-fuse-ld=gold --configure-option=CPPFLAGS=-I_build/generated '--gcc-options=-fno-stack-protector -I/home/chitrak/ghc/_build/generated -fuse-ld=gold' --configure-option=--with-cc=/usr/bin/gcc --with-gcc=/usr/bin/gcc --with-ld=/usr/bin/ld.gold --with-ar=/usr/bin/ar --with-alex=/usr/bin/alex --with-happy=/usr/bin/happy --flags=integer-gmp
@snowleopard the configure command used by hadrian

@chitrak7
Copy link
Contributor

@snowleopard It looks like the is supposed to be packagePath/dist-dir and not _build/stage1/packagePath. Can you look into this?

@snowleopard
Copy link
Owner

@chitrak7 Hadrian takes a different approach than Make in this respect. Make builds GHC right in the source tree, polluting it with build artefacts. Hadrian tries to put everything into the _build directory. Hadrian is still not perfect, but I think after @angerman's huge PR #445 is merged we'll have no more pollution of the source tree.

Note: this issue might still be related to what you've found. But, changing _build/stage1/packagePath to packagePath/distdir is not a good fix, Hadrian is supposed to produce stuff in _build.

@chitrak7
Copy link
Contributor

chitrak7 commented Mar 13, 2018

@snowleopard There is an interesting error in config.log:
configure:28447: checking for struct MD5Context
configure:28447: /usr/bin/gcc -c -I../.. -I../../../../includes -fno-stack-protector -I/home/chitrak/ghc/_build/generated -I_build/generated conftest.c >&5
conftest.c:216:10: fatal error: include/md5.h: No such file or directory
#include "include/md5.h"
^~~~~~~~~~~~~~~~~
compilation terminated.
The file does exist here.

@snowleopard
Copy link
Owner

@chitrak7 Thanks for investigating further! I've made a PR with a simple fix that works for me locally: #526. Let's see if it also works for you and our CI instances.

Note that my build still fails, but later:

Command: C:/msys/home/nam83/ghc/inplace/mingw/bin/gcc.exe -fno-stack-protector -Iincludes -I_build/generated -I_build/stage1/libraries/base -Ilibraries/base/include -Ilibraries/base/C:/msys/home/nam83/ghc/_build/stage1/libraries/base/build/include -IC:/msys/home/nam83/ghc/_build/stage1/rts -IC:/msys/home/nam83/ghc/includes -IC:/msys/home/nam83/ghc/_build/generated -E -MM -MG -MF _build/stage1/libraries/base/c/cbits/Win32Utils.o.d -MT _build/stage1/libraries/base/c/cbits/Win32Utils.o -x c libraries/base/cbits/Win32Utils.c
Exit code: 1
Stderr:
In file included from libraries/base/cbits/Win32Utils.c:9:0:
libraries/base/include/HsBase.h:294:2: error: #error at least ftruncate or _chsize functions are required to build
 #error at least ftruncate or _chsize functions are required to build
  ^~~~~

@chitrak7
Copy link
Contributor

@snowleopard It is because we are not including package directory in cflags. I think its a typo. The C file looks for a constatnt HAVE_UNISTD_H and HAVE_FTRUNCATE. This constant is stored in config log. so we have to include config.log along with this.

I tried to include library -I_build/stage1/libraries/base/build which didn't work. But including -Ilibraries/base did. both these directories contain the same config.log, but one is generated manually by me and other by hadrian.

@snowleopard snowleopard changed the title libraries/integer-gmp/gmp/config.mk - MISSING Error: at least ftruncate or _chsize functions are required to build Mar 14, 2018
@chitrak7
Copy link
Contributor

Continued..
This belief is further solidified by the fact that the command :
/usr/bin/gcc -fno-stack-protector -Iincludes -I_build/generated -I_build/stage1/libraries/process -I_build/stage1/libraries/process/build -Ilibraries/process/include -Ilibraries/process//home/chitrak/ghc/_build/stage1/libraries/process/build/include -Iinclude -I/home/chitrak/ghc/_build/stage1/libraries/process/build/include -I/home/chitrak/ghc/libraries/directory -I/home/chitrak/ghc/_build/stage1/libraries/directory -I/home/chitrak/ghc/libraries/unix/include -I/home/chitrak/ghc/libraries/unix/dist-install/build/include -I/home/chitrak/ghc/_build/stage1/libraries/unix/include -I/home/chitrak/ghc/_build/stage1/libraries/unix/dist-install/build/include -I/home/chitrak/ghc/libraries/time/lib/include -I/home/chitrak/ghc/libraries/time/lib/dist-install/build/include -I/home/chitrak/ghc/_build/stage1/libraries/time/lib/include -I/home/chitrak/ghc/_build/stage1/libraries/time/lib/dist-install/build/include -I/home/chitrak/ghc/libraries/bytestring/include -I/home/chitrak/ghc/libraries/bytestring/dist-install/build/include -I/home/chitrak/ghc/_build/stage1/libraries/bytestring/include -I/home/chitrak/ghc/_build/stage1/libraries/bytestring/dist-install/build/include -I/home/chitrak/ghc/libraries/base/include -I/home/chitrak/ghc/libraries/base/dist-install/build/include -I/home/chitrak/ghc/_build/stage1/libraries/base/include -I/home/chitrak/ghc/_build/stage1/libraries/base/dist-install/build/include -I/home/chitrak/ghc/libraries/integer-gmp/include -I/home/chitrak/ghc/libraries/integer-gmp/dist-install/build/include -I/home/chitrak/ghc/_build/stage1/libraries/integer-gmp/include -I/home/chitrak/ghc/_build/stage1/libraries/integer-gmp/dist-install/build/include -I/home/chitrak/ghc/_build/stage1/rts -I/home/chitrak/ghc/includes -I/home/chitrak/ghc/_build/generated -E -MM -MG -MF _build/stage1/libraries/process/c/cbits/runProcess.o.d -MT _build/stage1/libraries/process/c/cbits/runProcess.o -x c libraries/process/cbits/runProcess.c
Gives error: at least ftruncate or _chsize functions are required to build

But this command works without error:
sudo /usr/bin/gcc -fno-stack-protector -Iincludes -I_build/generated -I_build/stage1/libraries/process -I_build/stage1/libraries/process/build -Ilibraries/process/include -Ilibraries/process/ -I/home/chitrak/ghc/_build/stage1/libraries/process/build/include -Iinclude -I/home/chitrak/ghc/_build/stage1/libraries/process/build/include -I/home/chitrak/ghc/libraries/directory -I/home/chitrak/ghc/_build/stage1/libraries/directory -I/home/chitrak/ghc/libraries/unix/include -I/home/chitrak/ghc/libraries/unix/dist-install/build/include -I/home/chitrak/ghc/_build/stage1/libraries/unix/include -I/home/chitrak/ghc/_build/stage1/libraries/unix/dist-install/build/include -I/home/chitrak/ghc/libraries/time/lib/include -I/home/chitrak/ghc/libraries/time/lib/dist-install/build/include -I/home/chitrak/ghc/_build/stage1/libraries/time/lib/include -I/home/chitrak/ghc/_build/stage1/libraries/time/lib/dist-install/build/include -I/home/chitrak/ghc/libraries/bytestring/include -I/home/chitrak/ghc/libraries/bytestring/dist-install/build/include -I/home/chitrak/ghc/_build/stage1/libraries/bytestring/include -I/home/chitrak/ghc/_build/stage1/libraries/bytestring/dist-install/build/include -I/home/chitrak/ghc/libraries/base/include -I/home/chitrak/ghc/_build/stage1/libraries/base/build -I/home/chitrak/ghc/_build/stage1/libraries/base/build/include -I/home/chitrak/ghc/libraries/integer-gmp/include -I/home/chitrak/ghc/libraries/integer-gmp/dist-install/build/include -I/home/chitrak/ghc/_build/stage1/libraries/integer-gmp/include -I/home/chitrak/ghc/_build/stage1/libraries/integer-gmp/dist-install/build/include -I/home/chitrak/ghc/_build/stage1/rts -I/home/chitrak/ghc/includes -I/home/chitrak/ghc/_build/generated -E -MM -MG -MF _build/stage1/libraries/process/c/cbits/runProcess.o.d -MT _build/stage1/libraries/process/c/cbits/runProcess.o -x c libraries/process/cbits/runProcess.c

The changes in the above two commands are:
Removed directories : '/home/chitrak/ghc/_build/stage1/libraries/base/include' '/home/chitrak/ghc/_build/stage1/libraries/base/dist-install/build/include'
Added directories : '/home/chitrak/ghc/_build/stage1/libraries/base/build/include', '/home/chitrak/ghc/_build/stage1/libraries/base/build'

Can anyone please check into this.

@chitrak7
Copy link
Contributor

chitrak7 commented Mar 17, 2018

Changes done by me to pass for libraries/base.

diff --git a/src/Settings/Builders/Common.hs b/src/Settings/Builders/Common.hs
index bfcddeb..a8b7fdf 100644
--- a/src/Settings/Builders/Common.hs
+++ b/src/Settings/Builders/Common.hs
@@ -29,7 +29,9 @@ cIncludeArgs = do
     mconcat [ not (cross && compilerOrGhc) ? arg "-Iincludes"
                , arg $ "-I" ++ root -/- generatedDir
                , arg $ "-I" ++ path
+            , arg $ "-I" ++ path -/- "build"
                 , pure [ "-I" ++ pkgPath pkg -/- dir | dir <- incDirs ]
+            , pure [ "-I" ++ dir | dir <- incDirs ]
                  , pure [ "-I" ++       unifyPath dir | dir <- depDirs ] ]

@izgzhen @snowleopard

@izgzhen
Copy link
Collaborator Author

izgzhen commented Mar 18, 2018

| Run Ghc FindHsDependencies Stage1: libraries/xhtml/Text/XHtml.hs (and 14 more) => _build/stage1/libraries/xhtml/.dependencies.mk
| Remove file _build/stage1/libraries/xhtml/.dependencies.mk.bak
| Run Hsc2Hs: libraries/base/System/Environment/ExecutablePath.hsc => _build/stage1/libraries/base/System/Environment/ExecutablePath.hs
| Run Hsc2Hs: libraries/base/System/Environment/Blank.hsc => _build/stage1/libraries/base/System/Environment/Blank.hs
Blank.hsc:84:26: fatal error: HsBaseConfig.h: No such file or directory
compilation terminated.
compiling _build/stage1/libraries/base/System/Environment/Blank_hsc_make.c failed (exit code 1)
command was: /usr/bin/gcc -c _build/stage1/libraries/base/System/Environment/Blank_hsc_make.c -o _build/stage1/libraries/base/System/Environment/Blank_hsc_make.o -fno-stack-protector -Iincludes -I_build/generated -I_build/stage1/libraries/base -Ilibraries/base/include -Ilibraries/base//home/zhen/repos/ghc/_build/stage1/libraries/base/build/include -I/home/zhen/repos/ghc/libraries/integer-gmp/include -I/home/zhen/repos/ghc/libraries/integer-gmp/dist-install/build/include -I/home/zhen/repos/ghc/_build/stage1/libraries/integer-gmp/include -I/home/zhen/repos/ghc/_build/stage1/libraries/integer-gmp/dist-install/build/include -I/home/zhen/repos/ghc/_build/stage1/rts -I/home/zhen/repos/ghc/includes -I/home/zhen/repos/ghc/_build/generated -DOPTIMISE_INTEGER_GCD_LCM -Wall -Werror=unused-but-set-variable -Wno-error=inline -include _build/stage1/libraries/base/build/autogen/cabal_macros.h -Dx86_64_HOST_ARCH=1 -Dlinux_HOST_OS=1 -D__GLASGOW_HASKELL__=805
shakeArgsWith   0.000s    0%                           
Function shake  0.142s    0%                           
Database read   0.175s    0%                           
With database   0.010s    0%                           
Running rules  19.315s   98%  =========================
Total          19.642s  100%                           
Error when running Shake build system:
* _build/stage1/libraries/xhtml/libHSxhtml-3000.2.2_p.a
* _build/stage1/libraries/xhtml/Text/XHtml/Internals.p_o
* _build/stage1/libraries/xhtml/Text/XHtml/Internals.p_o _build/stage1/libraries/xhtml/Text/XHtml/Internals.p_hi
* _build/stage1/libraries/base/Data/Char.p_hi
* _build/stage1/libraries/base/Data/Char.p_o _build/stage1/libraries/base/Data/Char.p_hi
* OracleQ (KeyValues ("_build/stage1/libraries/base/.dependencies","_build/stage1/libraries/base/Data/Char.p_o"))
* _build/stage1/libraries/base/.dependencies
* _build/stage1/libraries/base/System/Environment/Blank.hs
user error (Development.Shake.cmd, system command failed
Command: _build/stage0/utils/hsc2hs/hsc2hs --cc=/usr/bin/gcc --ld=/usr/bin/gcc --cross-safe --cflag=-fno-stack-protector --cflag=-Iincludes --cflag=-I_build/generated --cflag=-I_build/stage1/libraries/base --cflag=-Ilibraries/base/include --cflag=-Ilibraries/base//home/zhen/repos/ghc/_build/stage1/libraries/base/build/include --cflag=-I/home/zhen/repos/ghc/libraries/integer-gmp/include --cflag=-I/home/zhen/repos/ghc/libraries/integer-gmp/dist-install/build/include --cflag=-I/home/zhen/repos/ghc/_build/stage1/libraries/integer-gmp/include --cflag=-I/home/zhen/repos/ghc/_build/stage1/libraries/integer-gmp/dist-install/build/include --cflag=-I/home/zhen/repos/ghc/_build/stage1/rts --cflag=-I/home/zhen/repos/ghc/includes --cflag=-I/home/zhen/repos/ghc/_build/generated --cflag=-DOPTIMISE_INTEGER_GCD_LCM --cflag=-Wall --cflag=-Werror=unused-but-set-variable --cflag=-Wno-error=inline --cflag=-include --cflag=_build/stage1/libraries/base/build/autogen/cabal_macros.h --lflag=-fuse-ld=gold --cflag=-Dx86_64_HOST_ARCH=1 --cflag=-Dlinux_HOST_OS=1 --cflag=-D__GLASGOW_HASKELL__=805 --template=/home/zhen/repos/ghc/inplace/lib/template-hsc.h libraries/base/System/Environment/Blank.hsc -o _build/stage1/libraries/base/System/Environment/Blank.hs
Exit code: 1
Stderr:
Blank.hsc:84:26: fatal error: HsBaseConfig.h: No such file or directory
compilation terminated.
compiling _build/stage1/libraries/base/System/Environment/Blank_hsc_make.c failed (exit code 1)
command was: /usr/bin/gcc -c _build/stage1/libraries/base/System/Environment/Blank_hsc_make.c -o _build/stage1/libraries/base/System/Environment/Blank_hsc_make.o -fno-stack-protector -Iincludes -I_build/generated -I_build/stage1/libraries/base -Ilibraries/base/include -Ilibraries/base//home/zhen/repos/ghc/_build/stage1/libraries/base/build/include -I/home/zhen/repos/ghc/libraries/integer-gmp/include -I/home/zhen/repos/ghc/libraries/integer-gmp/dist-install/build/include -I/home/zhen/repos/ghc/_build/stage1/libraries/integer-gmp/include -I/home/zhen/repos/ghc/_build/stage1/libraries/integer-gmp/dist-install/build/include -I/home/zhen/repos/ghc/_build/stage1/rts -I/home/zhen/repos/ghc/includes -I/home/zhen/repos/ghc/_build/generated -DOPTIMISE_INTEGER_GCD_LCM -Wall -Werror=unused-but-set-variable -Wno-error=inline -include _build/stage1/libraries/base/build/autogen/cabal_macros.h -Dx86_64_HOST_ARCH=1 -Dlinux_HOST_OS=1 -D__GLASGOW_HASKELL__=805
)

@chitrak7 I would like to help you but when I tried to build the latest source with ./build -j, the error above is thrown. I will clean up and try again though.

@chitrak7
Copy link
Contributor

Hi @izgzhen.
Can you please run this command instead:
/usr/bin/gcc -c _build/stage1/libraries/base/System/Environment/Blank_hsc_make.c -o _build/stage1/libraries/base/System/Environment/Blank_hsc_make.o -fno-stack-protector -Iincludes -I_build/generated -I_build/stage1/libraries/base -Ilibraries/base/include -Ilibraries/base/ -I/home/zhen/repos/ghc/_build/stage1/libraries/base/build/include -I/home/zhen/repos/ghc/_build/stage1/libraries/base/build -I/home/zhen/repos/ghc/libraries/integer-gmp/include -I/home/zhen/repos/ghc/libraries/integer-gmp/dist-install/build/include -I/home/zhen/repos/ghc/_build/stage1/libraries/integer-gmp/include -I/home/zhen/repos/ghc/_build/stage1/libraries/integer-gmp/dist-install/build/include -I/home/zhen/repos/ghc/_build/stage1/rts -I/home/zhen/repos/ghc/includes -I/home/zhen/repos/ghc/build/generated -DOPTIMISE_INTEGER_GCD_LCM -Wall -Werror=unused-but-set-variable -Wno-error=inline -include build/stage1/libraries/base/build/autogen/cabal_macros.h -Dx86_64_HOST_ARCH=1 -Dlinux_HOST_OS=1 -D__GLASGOW_HASKELL=805

@izgzhen
Copy link
Collaborator Author

izgzhen commented Mar 18, 2018

@chitrak7 thanks for your reply! I just hadrian/build.sh clean it before noticing your comment, and now the build is stuck similarly but for a different command:

| Run Ghc FindHsDependencies Stage1: libraries/integer-gmp/src/GHC/Integer.hs (and 4 more) => _build/stage1/libraries/integer-gmp/.dependencies.mk

libraries/integer-gmp/src/GHC/Integer/Type.hs:28:0: error:
     fatal error: HsIntegerGmp.h: No such file or directory
     #include "HsIntegerGmp.h"
     ^
   |
28 | #include "HsIntegerGmp.h"
   | ^
compilation terminated.
`gcc' failed in phase `C pre-processor'. (Exit code: 1)
shakeArgsWith   0.000s    0%                           
Function shake  0.133s    1%                           
Database read   0.200s    2%                           
With database   0.010s    0%                           
Running rules   7.472s   95%  =========================
Total           7.816s  100%                           
Error when running Shake build system:
* _build/stage1/libraries/integer-gmp/libHSinteger-gmp-1.0.1.0.a
* _build/stage1/libraries/integer-gmp/GHC/Integer/Type.o
* _build/stage1/libraries/integer-gmp/GHC/Integer/Type.o _build/stage1/libraries/integer-gmp/GHC/Integer/Type.hi
* OracleQ (KeyValues ("_build/stage1/libraries/integer-gmp/.dependencies","_build/stage1/libraries/integer-gmp/GHC/Integer/Type.o"))
* _build/stage1/libraries/integer-gmp/.dependencies
user error (Development.Shake.cmd, system command failed
Command: inplace/bin/ghc-stage1 -M -hisuf hi -osuf o -hcsuf hc -static -hide-all-packages -no-user-package-db '-this-unit-id integer-gmp-1.0.1.0' '-package-id ghc-prim-0.5.2.0' -i -i_build/stage1/libraries/integer-gmp -i_build/stage1/libraries/integer-gmp/build/autogen -ilibraries/integer-gmp/src/ -Iincludes -I_build/generated -I_build/stage1/libraries/integer-gmp -Ilibraries/integer-gmp/include -Ilibraries/integer-gmp//home/zhen/repos/ghc/_build/stage1/libraries/integer-gmp/build/include -I/home/zhen/repos/ghc/_build/stage1/rts -I/home/zhen/repos/ghc/includes -I/home/zhen/repos/ghc/_build/generated -I_build/generated -optc-I_build/generated -optP-include -optP_build/stage1/libraries/integer-gmp/build/autogen/cabal_macros.h -optc-fno-stack-protector -odir _build/stage1/libraries/integer-gmp -hidir _build/stage1/libraries/integer-gmp -stubdir _build/stage1/libraries/integer-gmp -include-pkg-deps -dep-makefile _build/stage1/libraries/integer-gmp/.dependencies.mk -dep-suffix '' -dep-suffix p_ -dep-suffix dyn_ libraries/integer-gmp/src/GHC/Integer.hs libraries/integer-gmp/src/GHC/Integer/GMP/Internals.hs libraries/integer-gmp/src/GHC/Integer/Logarithms.hs libraries/integer-gmp/src/GHC/Integer/Logarithms/Internals.hs libraries/integer-gmp/src/GHC/Integer/Type.hs -O2 -H32m -this-unit-id integer-gmp -Wall -XHaskell2010 -Wno-deprecated-flags
Exit code: 1
Stderr:
libraries/integer-gmp/src/GHC/Integer/Type.hs:28:0: error:
     fatal error: HsIntegerGmp.h: No such file or directory
     #include "HsIntegerGmp.h"
     ^
   |
28 | #include "HsIntegerGmp.h"
   | ^
compilation terminated.
`gcc' failed in phase `C pre-processor'. (Exit code: 1)
)

@chitrak7
Copy link
Contributor

chitrak7 commented Mar 18, 2018

Can you plaese run this command from ghc directory with sudo:
inplace/bin/ghc-stage1 -M -hisuf hi -osuf o -hcsuf hc -static -hide-all-packages -no-user-package-db '-this-unit-id integer-gmp-1.0.1.0' '-package-id ghc-prim-0.5.2.0' -i -i_build/stage1/libraries/integer-gmp -i_build/stage1/libraries/integer-gmp/build/autogen -ilibraries/integer-gmp/src/ -Iincludes -I_build/generated -I_build/stage1/libraries/integer-gmp -Ilibraries/integer-gmp/include -Ilibraries/integer-gmp/ -I/home/zhen/repos/ghc/_build/stage1/libraries/integer-gmp/build/include -I/home/zhen/repos/ghc/_build/stage1/libraries/integer-gmp/build/ -I/home/zhen/repos/ghc/_build/stage1/rts -I/home/zhen/repos/ghc/includes -I/home/zhen/repos/ghc/_build/generated -I_build/generated -optc-I_build/generated -optP-include -optP_build/stage1/libraries/integer-gmp/build/autogen/cabal_macros.h -optc-fno-stack-protector -odir _build/stage1/libraries/integer-gmp -hidir _build/stage1/libraries/integer-gmp -stubdir build/stage1/libraries/integer-gmp -include-pkg-deps -dep-makefile build/stage1/libraries/integer-gmp/.dependencies.mk -dep-suffix '' -dep-suffix p -dep-suffix dyn libraries/integer-gmp/src/GHC/Integer.hs libraries/integer-gmp/src/GHC/Integer/GMP/Internals.hs libraries/integer-gmp/src/GHC/Integer/Logarithms.hs libraries/integer-gmp/src/GHC/Integer/Logarithms/Internals.hs libraries/integer-gmp/src/GHC/Integer/Type.hs -O2 -H32m -this-unit-id integer-gmp -Wall -XHaskell2010 -Wno-deprecated-flags

@izgzhen
Copy link
Collaborator Author

izgzhen commented Mar 18, 2018

@chitrak7 same result:

libraries/integer-gmp/src/GHC/Integer/Type.hs:28:0: error:
     fatal error: HsIntegerGmp.h: No such file or directory
     #include "HsIntegerGmp.h"
     ^
   |
28 | #include "HsIntegerGmp.h"
   | ^
compilation terminated.
`gcc' failed in phase `C pre-processor'. (Exit code: 1)

@izgzhen
Copy link
Collaborator Author

izgzhen commented Mar 18, 2018

-> % find . -name "HsIntegerGmp.h"
./_build/stage1/libraries/integer-gmp/build/include/HsIntegerGmp.h

@izgzhen
Copy link
Collaborator Author

izgzhen commented Mar 18, 2018

I think we should include this as well...Err, bug is everywhere

@chitrak7
Copy link
Contributor

-Ilibraries/integer-gmp//home/zhen/repos/ghc/_build/stage1/libraries/integer-gmp/build/include
Its already included, but wrongly.

@chitrak7
Copy link
Contributor

@izgzhen odd, I replaced /zhen/repos to /chitrak in your command and ran it on my terminal. It worked. Are you sure you executed it from ghc and not hadrian?

@izgzhen
Copy link
Collaborator Author

izgzhen commented Mar 18, 2018

Are you sure you executed it from ghc and not hadrian

sure, otherwise the inplace/bin/ghc-stage1 won't be found.

@izgzhen
Copy link
Collaborator Author

izgzhen commented Mar 18, 2018

@chitrak7 https://github.com/snowleopard/hadrian/blob/master/src/Settings/Builders/Common.hs#L33 this line should be the one producing the wrong -I as you mentioned above.

@chitrak7
Copy link
Contributor

@izgzhen
Yeah! silly me :p. But I still believe the error is coming because of that inclusion only. All we need to do is add an additional path "_build/stage1/libraries/integer-gmp/build/include" to resolve this issue. I belive there is some typographical mistake here only. Can you retry by including this path as well, and removing the path "-Ilibraries/integer-gmp//home/zhen/repos/ghc/_build/stage1/libraries/integer-gmp/build/include".

@chitrak7
Copy link
Contributor

@izgzhen The issue is much deeper. Actually package-data.mk is supposed to keep these paths in the category INCLUDE_DEPS. But unfortunately, there one is relative and other absolute. Please refer to my earlier comment:
2) A discrepancy in INCLUDE_DIRS in package-data.mk
The file package-data.mk is supposed to give relative paths in category "INCLUDE_DIRS" while compiling a c file. This is evident from the code:

pure [ "-I" ++ pkgPath pkg -/- dir | dir <- incDirs ]
But here is how directories are listed in the file:
include /home/chitrak/ghc/_build/stage1/libraries/base/build/include
Here, "include" is relative while "/home/chitrak/ghc/_build/stage1/libraries/base/build/include" is absolute.

@izgzhen
Copy link
Collaborator Author

izgzhen commented Mar 18, 2018

Oh, I see why you patch looks like that. I am waiting for my build to finish with your patch. Thanks!

@chitrak7
Copy link
Contributor

Hopefully my patch will give error with process or unix library. Do inform me about the result. Also, did the HsIntegerConfig.hs error resolve by updating commands?

@izgzhen
Copy link
Collaborator Author

izgzhen commented Mar 18, 2018

@chitrak7 My build stopped at ftruncate or _chsize error. HsIntegerConfig is fine. Finally synced haha.

@chitrak7
Copy link
Contributor

chitrak7 commented Mar 18, 2018

With process library?? Or unix library? Can you give the final command.

@izgzhen
Copy link
Collaborator Author

izgzhen commented Mar 18, 2018

process library. I am trying out the change you described above now, wait a bit.

@izgzhen
Copy link
Collaborator Author

izgzhen commented Mar 18, 2018

@chitrak7

old: /usr/bin/gcc -fno-stack-protector -Iincludes -I_build/generated -I_build/stage1/libraries/process -I_build/stage1/libraries/process/build -Ilibraries/process/include -Ilibraries/process//home/zhen/repos/ghc/_build/stage1/libraries/process/build/include -Iinclude -I/home/zhen/repos/ghc/_build/stage1/libraries/process/build/include -I/home/zhen/repos/ghc/libraries/directory -I/home/zhen/repos/ghc/_build/stage1/libraries/directory -I/home/zhen/repos/ghc/libraries/unix/include -I/home/zhen/repos/ghc/libraries/unix/dist-install/build/include -I/home/zhen/repos/ghc/_build/stage1/libraries/unix/include -I/home/zhen/repos/ghc/_build/stage1/libraries/unix/dist-install/build/include -I/home/zhen/repos/ghc/libraries/time/lib/include -I/home/zhen/repos/ghc/libraries/time/lib/dist-install/build/include -I/home/zhen/repos/ghc/_build/stage1/libraries/time/lib/include -I/home/zhen/repos/ghc/_build/stage1/libraries/time/lib/dist-install/build/include -I/home/zhen/repos/ghc/libraries/bytestring/include -I/home/zhen/repos/ghc/libraries/bytestring/dist-install/build/include -I/home/zhen/repos/ghc/_build/stage1/libraries/bytestring/include -I/home/zhen/repos/ghc/_build/stage1/libraries/bytestring/dist-install/build/include -I/home/zhen/repos/ghc/libraries/base/include -I/home/zhen/repos/ghc/libraries/base/dist-install/build/include -I/home/zhen/repos/ghc/_build/stage1/libraries/base/include -I/home/zhen/repos/ghc/_build/stage1/libraries/base/dist-install/build/include -I/home/zhen/repos/ghc/libraries/integer-gmp/include -I/home/zhen/repos/ghc/libraries/integer-gmp/dist-install/build/include -I/home/zhen/repos/ghc/_build/stage1/libraries/integer-gmp/include -I/home/zhen/repos/ghc/_build/stage1/libraries/integer-gmp/dist-install/build/include -I/home/zhen/repos/ghc/_build/stage1/rts -I/home/zhen/repos/ghc/includes -I/home/zhen/repos/ghc/_build/generated -E -MM -MG -MF _build/stage1/libraries/process/c/cbits/runProcess.p_o.d -MT _build/stage1/libraries/process/c/cbits/runProcess.o -x c libraries/process/cbits/runProcess.c
=====
new: /usr/bin/gcc -fno-stack-protector -Iincludes -I_build/generated -I_build/stage1/libraries/process -I_build/stage1/libraries/process/build -Ilibraries/process/include -Ilibraries/process//home/zhen/repos/ghc/_build/stage1/libraries/process/build/include -Iinclude -I/home/zhen/repos/ghc/_build/stage1/libraries/process/build/include -I/home/zhen/repos/ghc/libraries/directory -I/home/zhen/repos/ghc/_build/stage1/libraries/directory -I/home/zhen/repos/ghc/libraries/unix/include -I/home/zhen/repos/ghc/libraries/unix/dist-install/build/include -I/home/zhen/repos/ghc/_build/stage1/libraries/unix/include -I/home/zhen/repos/ghc/_build/stage1/libraries/unix/dist-install/build/include -I/home/zhen/repos/ghc/libraries/time/lib/include -I/home/zhen/repos/ghc/libraries/time/lib/dist-install/build/include -I/home/zhen/repos/ghc/_build/stage1/libraries/time/lib/include -I/home/zhen/repos/ghc/_build/stage1/libraries/time/lib/dist-install/build/include -I/home/zhen/repos/ghc/libraries/bytestring/include -I/home/zhen/repos/ghc/libraries/bytestring/dist-install/build/include -I/home/zhen/repos/ghc/_build/stage1/libraries/bytestring/include -I/home/zhen/repos/ghc/_build/stage1/libraries/bytestring/dist-install/build/include -I/home/zhen/repos/ghc/libraries/base/include -I/home/zhen/repos/ghc/libraries/base/dist-install/build/include -I/home/zhen/repos/ghc/_build/stage1/libraries/base/build/include -I/home/zhen/repos/ghc/_build/stage1/libraries/base/dist-install/build/include -I/home/zhen/repos/ghc/libraries/integer-gmp/include -I/home/zhen/repos/ghc/libraries/integer-gmp/dist-install/build/include -I/home/zhen/repos/ghc/_build/stage1/libraries/integer-gmp/include -I/home/zhen/repos/ghc/_build/stage1/libraries/integer-gmp/dist-install/build/include -I/home/zhen/repos/ghc/_build/stage1/rts -I/home/zhen/repos/ghc/includes -I/home/zhen/repos/ghc/_build/generated -E -MM -MG -MF _build/stage1/libraries/process/c/cbits/runProcess.p_o.d -MT _build/stage1/libraries/process/c/cbits/runProcess.o -x c libraries/process/cbits/runProcess.c

the diff I made is changing -I/home/zhen/repos/ghc/_build/stage1/libraries/base/include to -I/home/zhen/repos/ghc/_build/stage1/libraries/base/build/include

@chitrak7
Copy link
Contributor

chitrak7 commented Mar 18, 2018

@izgzhen
You will need to add -I/home/zhen/repos/ghc/_build/stage1/libraries/base/build too.
It is required for HsBase.hs

@izgzhen
Copy link
Collaborator Author

izgzhen commented Mar 18, 2018

it is true -- how can we generalize this solution?

@chitrak7
Copy link
Contributor

chitrak7 commented Mar 18, 2018

@izgzhen
Please take a look at package-data.mk file of any library.
For example, with process it is at _build/stage1/linraries/process/package-data.mk.
We have to rewrite package-data.mk. We have to

  1. Remove descrepancy in INCLUDE_DIRS
  2. Remove bad directories from DEP_INCLUDE_DIRS
  3. Add required directories to DEP_INCLUDE_DIRS.
    Can you help me how to do this task?

@izgzhen
Copy link
Collaborator Author

izgzhen commented Mar 18, 2018

I’m not sure I know the solution but I guess it is related to how package-data.mk is formulated by Hadrian. I’ll take further look once I got some time ;)

@snowleopard
Copy link
Owner

@izgzhen @chitrak7 Thank you for investigating this further -- I hope I'll soon find some time to join! Just wanted to quickly add that we have a function that post-processes package-data files that are generated by ghc-cabal:

https://github.com/snowleopard/hadrian/blob/master/src/Rules/PackageData.hs#L100-L117

Maybe this is what needs to be tweaked.

Note that this issue will likely be gone after #445 is merged, since there will no longer be any ghc-cabal!

@angerman
Copy link
Collaborator

Note that this issue will likely be gone after #445 is merged, since there will no longer be any ghc-cabal!

Yes. @alpmestan has a working variant of #445 that drops ghc-cabal only (read: a subset of #445). Maybe just try to focus on that, and rather improve that new PR instead of trying to beat on ghc-cabal?

@angerman
Copy link
Collaborator

See PR #531.

@izgzhen
Copy link
Collaborator Author

izgzhen commented May 5, 2018

I will close this now, please reopen if something is left to be done

@izgzhen izgzhen closed this as completed May 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants