Bug 225377 - archivers/liblz4: setting TARGET_ARCH variable prevent to compile
Summary: archivers/liblz4: setting TARGET_ARCH variable prevent to compile
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Olivier Cochard
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-22 13:09 UTC by Olivier Cochard
Modified: 2019-02-14 14:54 UTC (History)
3 users (show)

See Also:
martin: maintainer-feedback+


Attachments
Patch fixing call with TARGET_ARCH (380 bytes, patch)
2018-01-22 13:09 UTC, Olivier Cochard
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Cochard freebsd_committer freebsd_triage 2018-01-22 13:09:31 UTC
Created attachment 189963 [details]
Patch fixing call with TARGET_ARCH

If you set TARGET_ARCH, like 'TARGET_ARCH=amd64', the port didn't compile any-more and fail with these error messages:

cc: error: no such file or directory: 'amd64'
cc: error: no such file or directory: 'amd64'

A proposal fix is attached.
Comment 1 Walter Schwarzenfeld freebsd_triage 2018-02-07 12:10:37 UTC
Cannot reproduce this error.
Comment 2 Martin Waschbüsch 2018-02-07 13:05:38 UTC
(In reply to Olivier Cochard from comment #0)

Olivier, can you give me more details?
For instance, what architecture are you running on when trying to cross-build for amd64?
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2018-02-07 15:18:41 UTC
This may be similar to 214778.  I would have to see an errorlog to make sure.
Comment 4 Olivier Cochard freebsd_committer freebsd_triage 2018-02-10 10:20:29 UTC
Here a full build log:

root@lame4:/usr/ports/archivers/liblz4 # uname -a
FreeBSD lame4.bsdrp.net 12.0-CURRENT FreeBSD 12.0-CURRENT #5 r328114: Thu Jan 18 11:22:16 CET 2018     olivier@lame4.bsdrp.net:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBUG  amd64
root@lame4:/usr/ports/archivers/liblz4 # make clean
===>  Cleaning for liblz4-1.8.1.2,1
root@lame4:/usr/ports/archivers/liblz4 # env 'TARGET_ARCH=amd64' make
===>  License BSD2CLAUSE GPLv2 accepted by the user
===>   liblz4-1.8.1.2,1 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by liblz4-1.8.1.2,1 for building
===>  Extracting for liblz4-1.8.1.2,1
=> SHA256 Checksum OK for lz4-lz4-v1.8.1.2_GH0.tar.gz.
===>  Patching for liblz4-1.8.1.2,1
===>   liblz4-1.8.1.2,1 depends on executable: gmake - found
===>   liblz4-1.8.1.2,1 depends on package: pkgconf>=1.3.0_1 - found
===>  Configuring for liblz4-1.8.1.2,1
===>  Building for liblz4-1.8.1.2,1
gmake[1]: Entering directory '/usr/local/poudriere/ports/default/archivers/liblz4/work/lz4-1.8.1.2'
gmake[2]: Entering directory '/usr/local/poudriere/ports/default/archivers/liblz4/work/lz4-1.8.1.2/lib'
compiling static library
compiling dynamic library 1.8.1
creating versioned links
gmake[2]: Leaving directory '/usr/local/poudriere/ports/default/archivers/liblz4/work/lz4-1.8.1.2/lib'
gmake[2]: Entering directory '/usr/local/poudriere/ports/default/archivers/liblz4/work/lz4-1.8.1.2/programs'
cc -O2 -pipe  -fstack-protector -fno-strict-aliasing    -I../lib -DXXH_NAMESPACE=LZ4_ amd64 -c -o bench.o bench.c
cc -O2 -pipe  -fstack-protector -fno-strict-aliasing    -I../lib -DXXH_NAMESPACE=LZ4_ amd64 -c -o datagen.o datagen.c
cc -O2 -pipe  -fstack-protector -fno-strict-aliasing    -I../lib -DXXH_NAMESPACE=LZ4_ amd64 -c -o lz4cli.o lz4cli.c
cc -O2 -pipe  -fstack-protector -fno-strict-aliasing    -I../lib -DXXH_NAMESPACE=LZ4_ amd64 -c -o lz4io.o lz4io.c
cc: error: no such file or directory: 'amd64'
cc: error: no such file or directory: 'amd64'
cc: error: no such file or directory: 'amd64'
gmake[2]: *** [<builtin>: bench.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
gmake[2]: *** [<builtin>: datagen.o] Error 1
gmake[2]: *** [<builtin>: lz4cli.o] Error 1
cc: error: no such file or directory: 'amd64'
gmake[2]: *** [<builtin>: lz4io.o] Error 1
gmake[2]: Leaving directory '/usr/local/poudriere/ports/default/archivers/liblz4/work/lz4-1.8.1.2/programs'
gmake[1]: *** [Makefile:68: lz4-release] Error 2
gmake[1]: Leaving directory '/usr/local/poudriere/ports/default/archivers/liblz4/work/lz4-1.8.1.2'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make: stopped in /usr/local/poudriere/ports/default/archivers/liblz4
Comment 5 Martin Waschbüsch 2018-02-10 15:04:57 UTC
(In reply to Olivier Cochard from comment #4)

Thank you, Olivier,

I was able to reproduce the described error.
Also, your patch does 'solve' the issue, but by forcibly unsetting the environment variable so that, in the end, running
env 'TARGET_ARCH=armv6' make
env 'TARGET_ARCH=i386' make
env 'TARGET_ARCH=amd64' make

all result in the very same library being built (namely the version for the arch you are running on):

file /usr/ports/archivers/liblz4/work/stage/usr/local/lib/liblz4.so.1.8.1
/usr/ports/archivers/liblz4/work/stage/usr/local/lib/liblz4.so.1.8.1: ELF 64-bit LSB shared object, x86-64, version 1 (FreeBSD), dynamically linked, stripped

I am all for improving the port, but this looks very wrong to me.
All the same, I'll dig into this some more and get back to you.

Martin
Comment 6 Walter Schwarzenfeld freebsd_triage 2018-03-07 21:38:08 UTC
env 'TARGET_ARCH=amd64' && make
                        ^^
Comment 7 Martin Waschbüsch 2018-03-07 21:49:03 UTC
(In reply to w.schwarzenfeld from comment #6)
Thanks Walter,

Doing that I also do not get any error.
Is the error then (only) in the syntax Oliver used?

(quoting from comment #4):
root@lame4:/usr/ports/archivers/liblz4 # env 'TARGET_ARCH=amd64' make
Comment 8 Walter Schwarzenfeld freebsd_triage 2018-03-07 22:03:17 UTC
I am not sure. If I try it with poudriere:
it fails with
.if ${.CURDIR:M/*ports/archivers/liblz4}
CONFIGURE_ENV+=        TARGET_ARCH=amd64
MAKE_ENV+=     TARGET_ARCH=amd64
.endif

Builds with success with
.if ${.CURDIR:M/*ports/archivers/liblz4}
TARGET_ARCH=    amd64
.endif
but:
the log shows:
#### /usr/ports/Mk/Scripts/ports_env.sh ####
_CCVERSION_921dbbb2=FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512 Targe
t: x86_64-unknown-freebsd10.4 Thread model: posix
_ALTCCVERSION_921dbbb2=none
_CXXINTERNAL_acaad9ca=FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512 Tar
get: x86_64-unknown-freebsd10.4 Thread model: posix "/usr/bin/ld" "--eh-frame-hdr" "-dynamic-linke
r" "/libexec/ld-elf.so.1" "--hash-style=both" "--enable-new-dtags" "-o" "a.out" "/usr/lib/crt1.o" 
"/usr/lib/crti.o" "/usr/lib/crtbegin.o" "-L/usr/lib" "/dev/null" "-lc++" "-lm" "-lgcc" "--as-neede
d" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "/usr/lib/crt
end.o" "/usr/lib/crtn.o"
OUTPUT_58173849_921dbbb2=yes
OUTPUT_9bdba57c_921dbbb2=yes
OUTPUT_6a4fe7f5_921dbbb2=yes
OUTPUT_6bcac02b_921dbbb2=yes
OUTPUT_67d20829_921dbbb2=yes
OUTPUT_bfa62e83_921dbbb2=yes
OUTPUT_f0b4d593_921dbbb2=yes
OUTPUT_308abb44_921dbbb2=yes
OUTPUT_f00456e5_921dbbb2=yes
OUTPUT_65ad290d_921dbbb2=error: invalid value 'c++14' in '-std=c++14' yes
OUTPUT_b2657cc3_921dbbb2=yes
OUTPUT_380987f7_921dbbb2=yes
ARCH=amd64
OPSYS=FreeBSD
_OSRELEASE=10.4-RELEASE-p5
OSREL=10.4
OSVERSION=1004000
:
get: x86_64-unknown-freebsd10.4 Thread model: posix "/usr/bin/ld" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld-elf.so.1" "--hash-style=both" "--enable-new-dtags" "-o" "a.out" "/usr/lib/crt1.o" "/usr/lib/crti.o" "/usr/lib/crtbegin.o" "-L/usr/lib" "/dev/null" "-lc++" "-lm" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "/usr/lib/crtend.o" "/usr/lib/crtn.o"
OUTPUT_58173849_921dbbb2=yes
OUTPUT_9bdba57c_921dbbb2=yes
OUTPUT_6a4fe7f5_921dbbb2=yes
OUTPUT_6bcac02b_921dbbb2=yes
OUTPUT_67d20829_921dbbb2=yes
OUTPUT_bfa62e83_921dbbb2=yes
OUTPUT_f0b4d593_921dbbb2=yes
OUTPUT_308abb44_921dbbb2=yes
OUTPUT_f00456e5_921dbbb2=yes
OUTPUT_65ad290d_921dbbb2=error: invalid value 'c++14' in '-std=c++14' yes
OUTPUT_b2657cc3_921dbbb2=yes
OUTPUT_380987f7_921dbbb2=yes
ARCH=amd64
OPSYS=FreeBSD
_OSRELEASE=10.4-RELEASE-p5
OSREL=10.4
Comment 9 Walter Schwarzenfeld freebsd_triage 2018-03-07 22:06:55 UTC
Oh, this was my error. Wrong clang version.
Build with poudriere with clang60 fine.
Comment 10 Walter Schwarzenfeld freebsd_triage 2018-03-07 22:20:40 UTC
I think env takes "make" as second argument. So it is not a command.
Comment 11 Walter Schwarzenfeld freebsd_triage 2018-03-07 22:53:42 UTC
Found this:
Bug #165480.
Here also as in the attachment:
You have first to set in the Makefile
MAKE_ENV+= TARGET_ARCH=
Comment 12 Martin Waschbüsch 2018-03-25 16:49:16 UTC
Comment on attachment 189963 [details]
Patch fixing call with TARGET_ARCH

patch accepted
Comment 13 Martin Waschbüsch 2018-03-26 13:56:24 UTC
(In reply to Olivier Cochard from comment #0)

Olivier,

can you please request approval for your patch, otherwise bugzilla does not allow me to give approval.

Thanks,

Martin
Comment 14 Olivier Cochard freebsd_committer freebsd_triage 2018-03-26 18:28:07 UTC
(In reply to Martin Waschbüsch from comment #13)

Your previous message "patch accepted" is enough I believe: I will commit it.
Comment 15 Walter Schwarzenfeld freebsd_triage 2019-02-12 23:19:26 UTC
ping! resp. I this still relevant?
Comment 16 Olivier Cochard freebsd_committer freebsd_triage 2019-02-13 06:58:49 UTC
Yes, it still relevant... but by reading the backlog, it seems it was my job to commit it and I forget to do it, right?
Comment 17 Walter Schwarzenfeld freebsd_triage 2019-02-13 07:01:20 UTC
Yes, seems right.
Comment 18 commit-hook freebsd_committer freebsd_triage 2019-02-14 14:49:31 UTC
A commit references this bug:

Author: olivier
Date: Thu Feb 14 14:49:19 UTC 2019
New revision: 492921
URL: https://svnweb.freebsd.org/changeset/ports/492921

Log:
  Fix compilation when TARGET_ARCH is set

  PR:		225377
  Approved by:	Martin Waschb?sch (maintainer)

Changes:
  head/archivers/liblz4/Makefile
Comment 19 Olivier Cochard freebsd_committer freebsd_triage 2019-02-14 14:54:42 UTC
Sorry to forgot to commit this patch lot's sooner.