Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: update meson.build to make it work on IBM i system #17193

Merged
merged 3 commits into from Oct 12, 2022

Conversation

zheddie
Copy link
Contributor

@zheddie zheddie commented Oct 11, 2022

Add extra options on IBM i to make the meson build/pip3 works. The changes are covered by host_machine.system() == 'os400', so, it would not affect any existing systems. Please help to review. Thanks.

@rgommers

@ilayn ilayn changed the title MAINT: update meson.build to make it works on i MAINT: update meson.build to make it work on IBM Oct 11, 2022
@ilayn ilayn added the Meson Items related to the introduction of Meson as the new build system for SciPy label Oct 11, 2022
Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @zheddie, thanks for the PR. I asked for two changes (threads dependency and using add_project_argument), with that it should be fine to merge. I do recommend trying to upstream this into Meson, so we can remove it again here. That way, it will also help Pandas, NumPy and everyone else who is moving to Meson.

meson.build Outdated
@@ -50,6 +50,13 @@ m_dep = cc.find_library('m', required : false)
if m_dep.found()
add_project_link_arguments('-lm', language : 'c')
endif
if host_machine.system() == 'os400'
add_global_arguments('-pthread', language : 'cpp')
add_global_arguments('-D__STDC_FORMAT_MACROS', language : 'cpp')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two lines should use add_project_argument rather than add_global_argument.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding __STDC_FORMAT_MACROS is fine - I guess the OS/400 C++ compiler is a bit outdated (modern C++ compilers should unconditionally define what's behind this macro - see https://stackoverflow.com/questions/8132399/how-to-printf-uint64-t-fails-with-spurious-trailing-in-format/8132440#8132440).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two lines should use add_project_argument rather than add_global_argument.

Yeah. I would try add_project_argument. BTW, in fact, by checking the build.ninja , we can find that "-pthread" could be added for some c++ source code, while, it only failed on some files , such as control.cc. To be honest , I didn't figure out why mason treat control.cc specially.

Adding __STDC_FORMAT_MACROS is fine - I guess the OS/400 C++ compiler is a bit outdated (modern C++ compilers should unconditionally define what's behind this macro - see https://stackoverflow.com/questions/8132399/how-to-printf-uint64-t-fails-with-spurious-trailing-in-format/8132440#8132440).

Yes, this is exactly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two lines should use add_project_argument rather than add_global_argument.

Last change: can you push this update?

@@ -50,6 +50,13 @@ m_dep = cc.find_library('m', required : false)
if m_dep.found()
add_project_link_arguments('-lm', language : 'c')
endif
if host_machine.system() == 'os400'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll note that this string isn't documented in https://mesonbuild.com/Reference-tables.html#operating-system-names, so not guaranteed to remain stable (although in practice, it shouldn't change).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. We didn't focus on mason , as we can smoothly(almost, except for the unkown CPU type. 😄 ) pip install it on our system. I would guess it's trying to using some python interface to get it. I am make sure this interface would not change to other value on my system, as "os400" exactly match our system.

meson.build Outdated Show resolved Hide resolved
rgommers added a commit to rgommers/scipy that referenced this pull request Oct 11, 2022
All could using `#include <thread>` needs to have this `thread_dep`
dependency. HiGHS code was missing it, and for `stats/_qmc_cy.pyx`
it was incorrectly specified.

It's wrong in the distutils build as well, but let's ignore that
since it's much harder to change and we'll get rid of that build
soon.

See scipygh-17193 for the type of compile error this causes.
rgommers added a commit that referenced this pull request Oct 12, 2022
All could using `#include <thread>` needs to have this `thread_dep`
dependency. HiGHS code was missing it, and for `stats/_qmc_cy.pyx`
it was incorrectly specified.

It's wrong in the distutils build as well, but let's ignore that
since it's much harder to change and we'll get rid of that build
soon.

See gh-17193 for the type of compile error this causes.

[ci skip]
@rgommers rgommers added backport-candidate This fix should be ported by a maintainer to previous SciPy versions. Build issues Issues with building from source, including different choices of architecture, compilers and OS labels Oct 12, 2022
add_global_arguments('-D__STDC_FORMAT_MACROS', language : 'cpp')
add_project_link_arguments('-Wl,-bnotextro', language : 'c')
add_project_link_arguments('-Wl,-bnotextro', language : 'cpp')
add_project_link_arguments('-Wl,-bnotextro', language : 'fortran')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a little tricky to find what this flag means. From the AIX 7.2 docs for ld:

notextro or nro: Does not check to ensure that there are no load time relocation entries for the text section of the output object file. This is the default.

So I guess on OS/400 it is not the default, unlike on AIX, and somehow this is a problem? For completeness it'd be nice to see the build error that shows up in the absence of this flag @zheddie.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. here's the error message if without those options:

[19/1566] Compiling C object scipy/special/libcephes.a.p/cephes_const.c.o
      [20/1566] Linking target scipy/_lib/_test_ccallback.cpython-39.so
      FAILED: scipy/_lib/_test_ccallback.cpython-39.so
      cc  -o scipy/_lib/_test_ccallback.cpython-39.so scipy/_lib/_test_ccallback.cpython-39.so.p/src__test_ccallback.c.o -Wl,-berok -Wl,-bnoipath -Wl,-bbigtoc -shared -fPIC -lm -Wl,-blibpath:/qopensys/pkgs/lib/gcc/powerpc-ibm-aix6.1.0.0/10:/qopensys/pkgs/lib/gcc:/qopensys/pkgs/lib:/lib:/usr/lib
      ld: 0711-302 ERROR: Object scipy/_lib/_test_ccallback.cpython-39.so.p/src__test_ccallback.c.o, csect <.text>
          The csect is part of the .text section, and relocation entries
          from the csect have been written to the .loader section.
      ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
      collect2: error: ld returned 8 exit status

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Interesting that it's AIX 6.1 with GCC, which seems to be working on other IBM hardware (I think, or we would have had more complaints by now) but not on IBM i system.

Anyway, this change looks good then. It's failing on the very first shared library being built, so it's going to fail on all of them. Hence adding a project-wide link argument seems fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh. Sorry, just noticed that I am still using the add_global_arguments(). It's a mis-match from my local system and build system. My test were donewith add_project_arguments() . So, reset the code change with correct one. Sorry about it.

As for the IBM i , yes, we are not AIX, and this is our first type trying using the pip3 directly on our system. Before that we are trying using the RPM to ship Scipy, which is not easy for us to keep pace with open source world.

@rgommers rgommers changed the title MAINT: update meson.build to make it work on IBM MAINT: update meson.build to make it work on IBM i system Oct 12, 2022
@rgommers rgommers added this to the 1.10.0 milestone Oct 12, 2022
Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now, thanks @zheddie

@rgommers rgommers merged commit 771de0a into scipy:main Oct 12, 2022
ev-br pushed a commit to ev-br/scipy that referenced this pull request Oct 14, 2022
All could using `#include <thread>` needs to have this `thread_dep`
dependency. HiGHS code was missing it, and for `stats/_qmc_cy.pyx`
it was incorrectly specified.

It's wrong in the distutils build as well, but let's ignore that
since it's much harder to change and we'll get rid of that build
soon.

See scipygh-17193 for the type of compile error this causes.

[ci skip]
ev-br pushed a commit to ev-br/scipy that referenced this pull request Oct 14, 2022
[ci skip]

Co-authored-by: GavinZhang <zhanggan@cn.ibm.com>
Co-authored-by: Ralf Gommers <ralf.gommers@gmail.com>
@tylerjereddy tylerjereddy modified the milestones: 1.10.0, 1.9.3 Oct 16, 2022
tylerjereddy pushed a commit to tylerjereddy/scipy that referenced this pull request Oct 16, 2022
[ci skip]

Co-authored-by: GavinZhang <zhanggan@cn.ibm.com>
Co-authored-by: Ralf Gommers <ralf.gommers@gmail.com>
tylerjereddy pushed a commit to tylerjereddy/scipy that referenced this pull request Oct 16, 2022
All could using `#include <thread>` needs to have this `thread_dep`
dependency. HiGHS code was missing it, and for `stats/_qmc_cy.pyx`
it was incorrectly specified.

It's wrong in the distutils build as well, but let's ignore that
since it's much harder to change and we'll get rid of that build
soon.

See scipygh-17193 for the type of compile error this causes.

[ci skip]
@tylerjereddy tylerjereddy removed the backport-candidate This fix should be ported by a maintainer to previous SciPy versions. label Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build issues Issues with building from source, including different choices of architecture, compilers and OS Meson Items related to the introduction of Meson as the new build system for SciPy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants