diorcety / crosstool-ng

crosstool-ng fork with the full support of Darwin/Linux/Windows as build and host machine
Other
33 stars 15 forks source link

cp -a bug (windows host) #15

Closed class101 closed 10 years ago

class101 commented 10 years ago

Something I already reported but you did not fixed, so test these sample cases on Windows and you will get it

Working fine

mkdir /x/cptest
mkdir /x/cptest/source/include -p
touch /x/cptest/source/include/testfile
mkdir /x/cptest/dest
cp -a /x/cptest/source/include /x/cptest/dest/include
=> /x/cptest/dest/include/testfile

Pathing bug

mkdir /x/cptest
mkdir /x/cptest/source/include -p
touch /x/cptest/source/include/testfile
mkdir /x/cptest/dest/include -p
cp -a /x/cptest/source/include /x/cptest/dest/include
=> /x/cptest/dest/include/include/testfile

Notice the double include path /x/cptest/dest/include/include/testfile

This is root cause of problems in 100-gcc.sh targeting Linux because your patch below is never installed correctly if "${prefix}/${CT_TARGET}/include" exists

    if [ "${copy_headers}" = "y" ]; then
        CT_DoLog DEBUG "Copying headers to install area of bootstrap gcc, so it can build libgcc2"
        CT_DoExecLog ALL cp -a "${CT_HEADERS_DIR}" "${prefix}/${CT_TARGET}/include"
    fi

or in a old build.sh patch

CT_DoExecLog ALL cp -a "${sysroot_dir}" "${prefix}/${CT_TARGET}/${sysroot_dir}"
mingwandroid commented 10 years ago

So you already have folders existing and that confuses the build system? I am not surprised.

For you own sanity, never build software into existing folders.

class101 commented 10 years ago

If it is existing I did not create it but the script huhu.. + I'm deleting manually all build folder before each builds so it is evident this folder has been created by the ct-ng fork or a patch and then this procedure fails.

class101 commented 10 years ago

If I do not do this

-        CT_DoExecLog ALL cp -a "${CT_HEADERS_DIR}" "${prefix}/${CT_TARGET}/include"
+        CT_DoExecLog ALL cp -a "${CT_HEADERS_DIR}" "${prefix}/${CT_TARGET}/"

I will end with an include error because you made ${prefix}/${CT_TARGET}/include/include

mingwandroid commented 10 years ago

I build linux targeting compilers frequently and they are usually fine. can you share a build.log of a failure?

class101 commented 10 years ago

Indeed I double checked the log but the folder doesn't seem to be created by ct-ng but instead I suspect it being created by binutils and its prefix=${CT_BUILDTOOLS_PREFIX_DIR} because next to the include folder is /bin/ with exactly, ar, as, ld, ld.bfd and strip (to note the folder is created but empty so it is just placeholder and safe to delete)

do_binutils_for_build() {
    local -a binutils_opts

    case "${CT_TOOLCHAIN_TYPE}" in
        native|cross)   return 0;;
    esac

    CT_DoStep INFO "Installing binutils for build"
    CT_mkdir_pushd "${CT_BUILD_DIR}/build-binutils-build-${CT_BUILD}"

    binutils_opts+=( "host=${CT_BUILD}" )
    binutils_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )

build.log:https://drive.google.com/file/d/0B4dcRcayW88VczNVNGxGMi1sOWM/edit?usp=sharing

mingwandroid commented 10 years ago

Thanks,

From your log:

[DEBUG] Already extracted 'mpfr-3.1.2' [DEBUG] Already patched 'mpfr-3.1.2' .. etc

.. so clearly you are not cleaning everything out. Please do that and give me the build.log again.

class101 commented 10 years ago

wait, this is first use problem, I should also clean the source folder before each builds ? because I never did :X I thought because we could set a custom source folder this allow us to keep the src extracted for next builds maybe I'm wrong but now you say it, I always build linux after windows so technically sources have already been used to build for windows targets when I'm building Linux, could explain why I have problems you don't have, thanks for noticing this

mingwandroid commented 10 years ago

You absolutely must delete the .build folders and the src folder is a subfolder of that. These 100% must also be deleted for correct results. The linux-kernel headers and glibc do parts of their build in the source tree. Do not try to save yourself 5 minutes because it ends up wasting time in the long run (such as this bug report)

class101 commented 10 years ago

Totally true , I feel so dumb now for just winning few seconds, thanks a lot for this

mingwandroid commented 10 years ago

ct-ng has facility for custom source folders ($HOME/src usually) but it only uses these to find cached tarballs and you should always make sure it re-extracts into clean folders on each and every build.