Bug 268981 - mk/Features/pie.mk: add cmake support (multimedia/cmrtlib: not WITH_PIE safe)
Summary: mk/Features/pie.mk: add cmake support (multimedia/cmrtlib: not WITH_PIE safe)
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: Alexander Leidinger
URL:
Keywords:
Depends on:
Blocks: 272898
  Show dependency treegraph
 
Reported: 2023-01-16 11:27 UTC by Alexander Leidinger
Modified: 2024-05-14 16:26 UTC (History)
5 users (show)

See Also:
tcberner: maintainer-feedback+


Attachments
use CMake support (509 bytes, patch)
2023-01-21 16:24 UTC, Jan Beich
no flags Details | Diff
use CMake support (523 bytes, patch)
2023-01-21 16:27 UTC, Jan Beich
jbeich: maintainer-approval? (portmgr)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Leidinger freebsd_committer freebsd_triage 2023-01-16 11:27:49 UTC
Hi,

building the port with WITH_PIE makes it fail (error message tells "-pie unused" during compilation). Until this is fixed, the port should get PIE_UNSAFE=yes in the Makefile (this fixes the build for me).

Bye,
Alexander.
Comment 1 Jan Beich freebsd_committer freebsd_triage 2023-01-21 16:24:34 UTC
Created attachment 239623 [details]
use CMake support

WITH_PIE should be using https://cmake.org/cmake/help/latest/variable/CMAKE_POSITION_INDEPENDENT_CODE.html instead of *blindly* forcing LDFLAGS+=-pie.
Comment 2 Jan Beich freebsd_committer freebsd_triage 2023-01-21 16:27:51 UTC
Created attachment 239624 [details]
use CMake support

CMAKE_ON helper doesn't work from within Mk/
Comment 3 Jan Beich freebsd_committer freebsd_triage 2023-05-04 05:09:47 UTC
^Triage: Reset Assignee after ports b5c25e6c4b7b
Comment 4 Gleb Popov freebsd_committer freebsd_triage 2024-01-08 17:40:46 UTC
The change makes sense overall and also fixes the problem with this specific port.

I'd say let's get this in, but it probably would invalidate a lot of exp-run results in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=272898

Thanks for working on this, Jan, please push this in.
Comment 5 Ed Maste freebsd_committer freebsd_triage 2024-01-08 17:55:15 UTC
> it probably would invalidate a lot of exp-run results

If this fixes a general class of problem we can just request another exp-run in 272898 after it's in.  (That said it looks like the biggest issues in the exp-run are caused by gfortran.)
Comment 6 Gleb Popov freebsd_committer freebsd_triage 2024-04-09 06:37:50 UTC
Alexander, can you land this?
Comment 7 Alexander Leidinger freebsd_committer freebsd_triage 2024-04-09 07:32:00 UTC
(In reply to Gleb Popov from comment #6)

I assume you don't mean my initial workaround, but the CMake part of jbeich. Correct?

If correct: I further assume this is not a request of blindly committing that sane-looking (I don't know enough about cmake to be sure, but it looks at least sane) patch, but about working with portmgr about an exp-run and so on. Correct?

If my understanding is correct: yes, I can do that.
Comment 8 Gleb Popov freebsd_committer freebsd_triage 2024-04-09 07:34:35 UTC
Yes, I was talking about Jan's patch, sorry.

However, I don't think it requires an exp-run because PIE is turned off by default. It merely will improve the situation for the consecutive WITH_PIE=yes exp-run in future.
Comment 9 Alexander Leidinger freebsd_committer freebsd_triage 2024-04-09 07:55:37 UTC
The patch fixes the PIE build of multimedia/cmrtlib, math/blas and math/lapack (those cmake ports which failed PIE build in my own poudriere runs).

I assume this will fix a lot of the cmake-using ports. This also solves Bug 268985.
Comment 10 Alexander Leidinger freebsd_committer freebsd_triage 2024-04-09 08:01:29 UTC
portmgr, is an PIE-enabled exp-run needed, or do you want to do one anyway, or can I commit this? For a validation see the comment above this one.
Comment 11 Tobias C. Berner freebsd_committer freebsd_triage 2024-05-14 05:08:51 UTC
(In reply to Alexander Leidinger from comment #10)
Moin moin 

As it is off by default, I think we can get this in without an exp-run.

Please go ahead.

mfg Tobias
Comment 12 commit-hook freebsd_committer freebsd_triage 2024-05-14 08:40:28 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b40aa97071012f71a9c8937ef41d3153f070243f

commit b40aa97071012f71a9c8937ef41d3153f070243f
Author:     Jan Beich <jbeich@FreeBSD.org>
AuthorDate: 2024-05-14 08:35:00 +0000
Commit:     Alexander Leidinger <netchild@FreeBSD.org>
CommitDate: 2024-05-14 08:39:24 +0000

    Mk/Features: WITH_PIE - add cmake support

    Use cmake specific options to enable position independent code generation.

    This fixes several ports (at least multimedia/cmrtlib, math/blas and
    math/lapack) which are build with cmake when WITH_PIE is enabled.

    PR:             268981
    Approved by:    portmgr

 Mk/Features/pie.mk | 4 ++++
 1 file changed, 4 insertions(+)
Comment 13 Thierry Thomas freebsd_committer freebsd_triage 2024-05-14 16:26:12 UTC
At netchild's request, I tested some Fortran ports with the proposed patch with WITH_PIE: most of them are safe, but I noticed 3 failures.

1) science/hdf5-110
Fails to configure:

checking for Fortran libraries of gfortran13...  -L/usr/local/lib/gcc13 -L/usr/local/lib -L/usr/local/lib/gcc13/gcc/x86_64-portbld-freebsd15.0/13.2.0 -L/usr/local/lib/gcc13/gcc/x86_64-portbld-freebsd15.0/13.2.0/../../../../../x86_64-portbld-freebsd15.0/lib -L/usr/local/lib/gcc13/gcc/x86_64-portbld-freebsd15.0/13.2.0/../../.. -lgfortran -lm -lssp_nonshared -lquadmath
checking for dummy main to link with Fortran libraries... none
checking for Fortran name-mangling scheme... lower case, underscore, no extra underscore
checking if Fortran compiler supports intrinsic SIZEOF... no
checking if Fortran compiler supports intrinsic C_SIZEOF... no
checking if Fortran compiler supports intrinsic STORAGE_SIZE... no
configure: error: Fortran compiler requires either intrinsic functions SIZEOF or STORAGE_SIZE

2) math/mumps
Linkage failure with MPI stuff (does not seems related to PIE, but it usually builds fine):

gfortran13 -shared lr_common.o ana_omp_m.o ana_orderings_wrappers_m.o mumps_memory_mod.o mumps_static_mapping.o mumps_sol_es.o fac_future_niv2_mod.o mumps_comm_ibcast.o mumps_ooc_common.o double_linked_list.o fac_asm_build_sort_index_m.o fac_asm_build_sort_index_ELT_m.o omp_tps_common_m.o mumps_l0_omp_m.o front_data_mgt_m.o fac_maprow_data_m.o fac_descband_data_m.o fac_ibct_data_m.o ana_orderings.o ana_AMDMF.o bcast_errors.o estim_flops.o mumps_type_size.o mumps_type2_blocking.o mumps_version.o tools_common.o mumps_print_defined.o mumps_common.o mumps_pord.o mumps_metis.o mumps_metis64.o mumps_metis_int.o mumps_scotch.o mumps_scotch64.o mumps_scotch_int.o mumps_size.o mumps_io.o mumps_io_basic.o mumps_io_thread.o mumps_io_err.o ana_set_ordering.o mumps_numa.o mumps_thread.o mumps_save_restore_C.o -Wl,-soname,libmumps_common.so.5 -L../lib -L/usr/local/lib -lmetis -L../PORD/lib/ -lpord -L/lib -lesmumps -lscotch -lscotcherr -lz  -lpthread  -L/usr/local/lib -Wl,-rpath=/usr/local/lib/gcc13  -L/usr/local/lib/gcc13 -pie -fstack-protector-strong  -lgfortran -o ../lib/libmumps_common.so.5
/usr/local/bin/ld: /usr/lib/Scrt1.o: in function `_start':
/usr/src/lib/csu/amd64/crt1_s.S:67: undefined reference to `main'
/usr/local/bin/ld: mumps_static_mapping.o: in function `__mumps_static_mapping_MOD_mumps_compute_distrib':
mumps_static_mapping.F:(.text+0x255c): undefined reference to `mpi_get_processor_name_'
/usr/local/bin/ld: mumps_static_mapping.F:(.text+0x2803): undefined reference to `mpi_bcast_'
/usr/local/bin/ld: mumps_static_mapping.F:(.text+0x2bd0): undefined reference to `mpi_bcast_'
/usr/local/bin/ld: mumps_static_mapping.o: in function `__mumps_static_mapping_MOD_mumps_init_arch_parameters':
mumps_static_mapping.F:(.text+0x3a07): undefined reference to `mpi_comm_rank_'
/usr/local/bin/ld: mumps_static_mapping.F:(.text+0x3a51): undefined reference to `mpi_comm_rank_'
/usr/local/bin/ld: mumps_static_mapping.F:(.text+0x3ed3): undefined reference to `mpi_allreduce_'
/usr/local/bin/ld: bcast_errors.o: in function `mumps_propinfo_':
bcast_errors.F:(.text+0x67): undefined reference to `mpi_allreduce_'
/usr/local/bin/ld: tools_common.o: in function `mumps_abort_':
tools_common.F:(.text+0x25): undefined reference to `mpi_abort_'
/usr/local/bin/ld: tools_common.o: in function `mumps_secdeb_':
tools_common.F:(.text+0x692): undefined reference to `mpi_wtime_'
/usr/local/bin/ld: tools_common.o: in function `mumps_secfin_':
tools_common.F:(.text+0x6b7): undefined reference to `mpi_wtime_'
/usr/local/bin/ld: tools_common.o: in function `mumps_mem_centralize_':
tools_common.F:(.text+0x9e6): undefined reference to `mpi_reduce_'
/usr/local/bin/ld: tools_common.F:(.text+0xa2e): undefined reference to `mpi_reduce_'
/usr/local/bin/ld: tools_common.F:(.text+0xa84): undefined reference to `mpi_reduce_'
/usr/local/bin/ld: tools_common.o: in function `mumps_bcast_i8_':
tools_common.F:(.text+0x1179): undefined reference to `mpi_bcast_'
/usr/local/bin/ld: tools_common.o: in function `mumps_reducei8_':
tools_common.F:(.text+0x11fe): undefined reference to `mpi_reduce_'
/usr/local/bin/ld: tools_common.o: in function `mumps_allreducei8_':
tools_common.F:(.text+0x1284): undefined reference to `mpi_allreduce_'
/usr/local/bin/ld: tools_common.o: in function `mumps_get_proc_per_node_':
tools_common.F:(.text+0x2558): undefined reference to `mpi_get_processor_name_'
/usr/local/bin/ld: tools_common.F:(.text+0x27d1): undefined reference to `mpi_bcast_'
/usr/local/bin/ld: tools_common.F:(.text+0x2b66): undefined reference to `mpi_bcast_'
collect2: error: ld returned 1 exit status

3) net/openmpi
Fails at configure:
checking if Fortran compiler works... no
**********************************************************************
* It appears that your Fortran compiler is unable to produce working
* executables.  A simple test application failed to properly
* execute.  Note that this is likely not a problem with Open MPI,
* but a problem with the local compiler installation.  More
* information (including exactly what command was given to the
* compiler and what error resulted when the command was executed) is
* available in the config.log file in the Open MPI build directory.
**********************************************************************
configure: error: Could not run a simple Fortran program.  Aborting.