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

Fix build on AIX and SunOS (#8373) #9065

Merged
merged 1 commit into from Oct 11, 2021
Merged

Fix build on AIX and SunOS (#8373) #9065

merged 1 commit into from Oct 11, 2021

Conversation

scddev
Copy link
Contributor

@scddev scddev commented Oct 6, 2021

  • fix includes for AIX and SunOS

* fix includes for AIX and SunOS
@google-cla
Copy link

@google-cla google-cla bot commented Oct 6, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Oct 6, 2021
@scddev
Copy link
Contributor Author

@scddev scddev commented Oct 6, 2021

@googlebot I signed it!

@google-cla
Copy link

@google-cla google-cla bot commented Oct 6, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@elharo
Copy link
Contributor

@elharo elharo commented Oct 6, 2021

Are people still using pre-Solaris SunOS? Or is this for Solaris?

I wonder if we could set up a Github action on one or both of these platforms to test this?

@elharo elharo added c++ platform related release notes: yes labels Oct 6, 2021
@scddev
Copy link
Contributor Author

@scddev scddev commented Oct 6, 2021

In my case I used Solaris 10, so maybe Solaris would be the better name. I can modify the commit message if you like.

@scddev
Copy link
Contributor Author

@scddev scddev commented Oct 6, 2021

@googlebot I signed it!

@google-cla google-cla bot added cla: yes and removed cla: no labels Oct 6, 2021
@gdharley
Copy link

@gdharley gdharley commented Oct 6, 2021

Can we make sure that any AIX fix includes support for xlC and gcc compilers on AIX.

@elharo
Copy link
Contributor

@elharo elharo commented Oct 6, 2021

@gdharley Are you asking that we also support xLC and gcc, or are you worried that this might break support that is already working?

@gdharley
Copy link

@gdharley gdharley commented Oct 6, 2021

We use gcc on AIX and while protobufs compile, there are linking issues with libstdc++ which means protoc when executed has missing symbols. I have tried linking against every libstdc++ available and always different symbols are missing. Have manually edited the Makefile and can't see anything wrong.

@scddev
Copy link
Contributor Author

@scddev scddev commented Oct 6, 2021

To get around the dependencies to libstdc++ or libgcc we use LDFLAGS -static-libgcc -static-libstdc++.

Btw, we are using the cmake build instead of the autotools build. But also cmake build needs some tweaks to work. For AIX we are using a toolchain file as cmake by default generates some commands wrong (ar, ranlib).

@gdharley
Copy link

@gdharley gdharley commented Oct 6, 2021

Thanks Dietmar, I thought I had tried static linking, will try again.
I guess it is all these tweaks that need to be fixed to properly support gcc on AIX.

@scddev
Copy link
Contributor Author

@scddev scddev commented Oct 7, 2021

To get you started, here my toolchain.cmake:

set(CMAKE_C_FLAGS_INIT "-maix64 -pthread")
set(CMAKE_CXX_FLAGS_INIT "-maix64 -pthread")
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-static-libgcc -static-libstdc++ -Wl,-bbigtoc")
set(CMAKE_EXE_LINKER_FLAGS_INIT "-static-libgcc -static-libstdc++ -Wl,-bbigtoc")

set(CMAKE_C_ARCHIVE_CREATE
    "<CMAKE_AR> <LINK_FLAGS> -X64 qc <TARGET> <OBJECTS>")
set(CMAKE_C_ARCHIVE_APPEND
    "<CMAKE_AR> <LINK_FLAGS> -X64 q <TARGET> <OBJECTS>")
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -X64 <TARGET>")

set(CMAKE_CXX_ARCHIVE_CREATE
    "<CMAKE_AR> <LINK_FLAGS> -X64 qc <TARGET> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_APPEND
    "<CMAKE_AR> <LINK_FLAGS> -X64 q <TARGET> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -X64 <TARGET>")

Now I can build with:

cd cmake
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake
cmake --build build

This yields:

$ file build/protoc
build/protoc: 64-bit XCOFF executable or object module not stripped
$ ldd build/protoc
build/protoc needs:
         /opt/freeware/lib/libz.a(libz.so.1)
         /usr/lib/libpthreads.a(shr_xpg5_64.o)
         /usr/lib/libc.a(shr_64.o)
         /unix
         /usr/lib/libcrypt.a(shr_64.o)
$ build/protoc --version
libprotoc 3.18.1

@acozzette acozzette merged commit 3bdcc12 into protocolbuffers:master Oct 11, 2021
46 checks passed
@acozzette
Copy link
Member

@acozzette acozzette commented Oct 11, 2021

@scddev Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ cla: yes platform related release notes: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants