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

Update macos build #2638

Merged
merged 7 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ let package = Package(
"src/Ice/Ice.rc",
"src/Ice/Makefile.mk",
"src/Ice/DLLMain.cpp",
"src/Ice/RegisterPluginsInit_min.cpp",
"src/Ice/SSL/SchannelEngine.cpp",
"src/Ice/SSL/SchannelTransceiverI.cpp",
"src/Ice/SSL/OpenSSLTransceiverI.cpp",
Expand Down
1 change: 0 additions & 1 deletion config/Make.project.rules
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,6 @@ static_ldflags += $$(call make-ldflags,$$(call get-all-deps,$4),make-st

# Shared configuration for shared builds
shared_projects = %
shared_objdir = $(if $(filter-out program,$($1_target)),shared/pic,shared/pie)
shared_targetrule = $(if $(filter-out program,$($1_target)),shared)
shared_cppflags += $(strip $(call make-lib-cppflags,$4))
shared_ldflags += $$(call make-ldflags,$($4_dependencies),make-shared-dep-ldflags,$4,unique)\
Expand Down
11 changes: 7 additions & 4 deletions config/Make.rules.Darwin
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,20 @@ MCPP_HOME ?= $(shell brew --prefix mcpp)
LMDB_HOME ?= $(shell brew --prefix lmdb)
endif

# If building objects for a shared library build, enable PIC or PIE:
shared_cppflags = $(if $(filter-out program,$($1_target)),-fPIC,-fPIE) -fvisibility=hidden

cppflags = -Wall -Wextra -Wshadow -Wshadow-all -Wredundant-decls -Wno-shadow-field \
# On macos, objects are always PIC/PIE, and executables are always PIE. So there is no need to pass -fPIC or -fPIE to
# the compiler.
cppflags = -fvisibility=hidden -Wall -Wextra -Wshadow -Wshadow-all -Wredundant-decls -Wno-shadow-field \
-Wdeprecated -Wstrict-prototypes -Werror -Wconversion -Wdocumentation -pthread \
$(if $(filter yes,$(OPTIMIZE)),-O2 -DNDEBUG,-g)

ifeq ($(MAXWARN),yes)
cppflags += -Wweak-vtables
endif

# We compile static and shared with the same flags so we want their .o to share directories.
static_objdir = obj
shared_objdir = obj

clang_version = $(shell clang -dumpversion 2>&1 | cut -f1 -d\.)

# We use -std=c++20 with clang 15.0 and later.
Expand Down
3 changes: 2 additions & 1 deletion config/Make.rules.Linux
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ endif
rpath-link-ldflag = -Wl,-rpath-link,$1
make-rpath-link-ldflags = $(foreach d,$(filter-out $2,$(call get-all-deps,$1)),$(call rpath-link-ldflag,$($d_targetdir)))

# If building objects for a shared library build, enable PIC or PIE:
# If building objects for a shared library build, enable PIC or PIE and segregate the objects
shared_cppflags = $(if $(filter-out program,$($1_target)),-fPIC,-fPIE) -fvisibility=hidden
shared_objdir = $(if $(filter-out program,$($1_target)),shared/pic,shared/pie)

# If we are linking a program, add -rpath-link to locate secondary libraries that aren't linked with the executable.
shared_ldflags = $(if $(filter-out program,$($1_target)),\
Expand Down
1 change: 1 addition & 0 deletions cpp/config/Make.rules
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static_components = $(coreandstub_components)
static_projects = test/Common \
test/Ice/% \
test/IceSSL/% \
test/IceUtil/stacktrace \
test/IceDiscovery/simple \
test/Glacier2/application \
test/IceGrid/simple
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/Glacier2CryptPermissionsVerifier/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $(project)_libraries += Glacier2CryptPermissionsVerif

Glacier2CryptPermissionsVerifier_targetdir := $(libdir)
Glacier2CryptPermissionsVerifier_dependencies := Glacier2 Ice
Glacier2CryptPermissionsVerifier[shared]_cppflags := -DCRYPT_PERMISSIONS_VERIFIER_API_EXPORTS
Glacier2CryptPermissionsVerifier_cppflags := -DCRYPT_PERMISSIONS_VERIFIER_API_EXPORTS
Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted an earlier commit that add "[shared]". We want to use exactly the same flags for static and shared builds on macos.

Glacier2CryptPermissionsVerifier_devinstall := no

projects += $(project)
2 changes: 1 addition & 1 deletion cpp/src/Glacier2Lib/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $(project)_libraries := Glacier2

Glacier2_targetdir := $(libdir)
Glacier2_dependencies := Ice
Glacier2[shared]_cppflags := -DGLACIER2_API_EXPORTS
Glacier2_cppflags := -DGLACIER2_API_EXPORTS
Glacier2_sliceflags := --include-dir Glacier2

projects += $(project)
2 changes: 1 addition & 1 deletion cpp/src/Ice/Exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
# endif
# endif

# if !defined(__FreeBSD__) && defined(ICE_API_EXPORTS)
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if we can remove this defined(ICE_API_EXPORTS). It seems to work fine on macos. Would be good to test on Linux with a static build.

# if !defined(__FreeBSD__)
# include <cxxabi.h>
# include <execinfo.h>
# include <stdint.h>
Expand Down
7 changes: 5 additions & 2 deletions cpp/src/Ice/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
$(project)_libraries = Ice

Ice_targetdir := $(libdir)
Ice_cppflags = $(IceUtil_cppflags)
Ice[shared]_cppflags := -DICE_API_EXPORTS
Ice_cppflags = -DICE_API_EXPORTS $(IceUtil_cppflags)

Ice_sliceflags := --include-dir Ice
Ice_libs := bz2
Expand All @@ -16,7 +15,11 @@ Ice_extra_sources := $(filter-out src/Ice/SSL/OpenSSL%.cpp src/Ice/SSL/Sch
else
Ice_extra_sources := $(filter-out src/Ice/SSL/SecureTransport%.cpp src/Ice/SSL/Schannel%.cpp, $(wildcard src/Ice/SSL/*.cpp))
endif

Ice_excludes = src/Ice/DLLMain.cpp
Ice[shared]_excludes = src/Ice/RegisterPluginsInit_min.cpp
Copy link
Member Author

Choose a reason for hiding this comment

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

That's how I can use the same flags for static/shared build and yet get a small configuration-specific behavior: include a different impl file depending on the configuration.

Ice[xcodesdk]_excludes = src/Ice/RegisterPluginsInit_min.cpp
Ice[static]_excludes = src/Ice/RegisterPluginsInit_all.cpp

ifeq ($(os),Linux)
ifeq ($(shell pkg-config --exists libsystemd 2> /dev/null && echo yes),yes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
// Copyright (c) ZeroC, Inc. All rights reserved.
//

#include "RegisterPluginsInit.h"
#include "Ice/CommunicatorF.h"
#include "Ice/Initialize.h"
#include "RegisterPluginsInit.h"

extern "C"
{
Ice::Plugin* createStringConverter(const Ice::CommunicatorPtr&, const std::string&, const Ice::StringSeq&);
Ice::Plugin* createIceUDP(const Ice::CommunicatorPtr&, const std::string&, const Ice::StringSeq&);
Ice::Plugin* createIceTCP(const Ice::CommunicatorPtr&, const std::string&, const Ice::StringSeq&);
Ice::Plugin* createIceWS(const Ice::CommunicatorPtr&, const std::string&, const Ice::StringSeq&);
Expand All @@ -20,11 +19,7 @@ IceInternal::RegisterPluginsInit::RegisterPluginsInit()
Ice::registerPluginFactory("IceTCP", createIceTCP, true);
Ice::registerPluginFactory("IceSSL", createIceSSL, true);

//
// Include the UDP and WS transport plugins with non-static builds.
//
#if defined(ICE_API_EXPORTS)
// Include the UDP and WS transport plugins with "shared" builds.
Copy link
Member Author

Choose a reason for hiding this comment

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

That's the implementation (_all) we want to use/include in all builds, except the configuration=static build.

Ice::registerPluginFactory("IceUDP", createIceUDP, true);
Ice::registerPluginFactory("IceWS", createIceWS, true);
#endif
}
19 changes: 19 additions & 0 deletions cpp/src/Ice/RegisterPluginsInit_min.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

#include "Ice/CommunicatorF.h"
#include "Ice/Initialize.h"
#include "RegisterPluginsInit.h"

extern "C"
{
Ice::Plugin* createIceTCP(const Ice::CommunicatorPtr&, const std::string&, const Ice::StringSeq&);
Ice::Plugin* createIceSSL(const Ice::CommunicatorPtr&, const std::string&, const Ice::StringSeq&);
}

IceInternal::RegisterPluginsInit::RegisterPluginsInit()
{
Ice::registerPluginFactory("IceTCP", createIceTCP, true);
Ice::registerPluginFactory("IceSSL", createIceSSL, true);
}
2 changes: 1 addition & 1 deletion cpp/src/Ice/msbuild/ice/ice.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@
<ClCompile Include="..\..\Proxy.cpp" />
<ClCompile Include="..\..\Reference.cpp" />
<ClCompile Include="..\..\ReferenceFactory.cpp" />
<ClCompile Include="..\..\RegisterPluginsInit.cpp" />
<ClCompile Include="..\..\RegisterPluginsInit_all.cpp" />
<ClCompile Include="..\..\RequestHandler.cpp" />
<ClCompile Include="..\..\RetryQueue.cpp" />
<ClCompile Include="..\..\RouterInfo.cpp" />
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/Ice/msbuild/ice/ice.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@
<ClCompile Include="..\..\ReferenceFactory.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\RegisterPluginsInit.cpp">
<ClCompile Include="..\..\RegisterPluginsInit_all.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\RequestHandler.cpp">
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/IceBT/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ $(project)_libraries := IceBT

IceBT_targetdir := $(libdir)
IceBT_dependencies := Ice
IceBT_cppflags := $(shell pkg-config --cflags dbus-1)
IceBT[shared]_cppflags := -DICEBT_API_EXPORTS
IceBT_cppflags := -DICEBT_API_EXPORTS $(shell pkg-config --cflags dbus-1)

projects += $(project)
endif
2 changes: 1 addition & 1 deletion cpp/src/IceDB/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $(project)_libraries = IceDB
IceDB_targetdir := $(libdir)
IceDB_dependencies := Ice
IceDB_libs := lmdb
IceDB[shared]_cppflags := -DICE_DB_API_EXPORTS
IceDB_cppflags := -DICE_DB_API_EXPORTS
IceDB_devinstall := no

projects += $(project)
2 changes: 1 addition & 1 deletion cpp/src/IceDiscovery/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ $(project)_libraries := IceDiscovery

IceDiscovery_targetdir := $(libdir)
IceDiscovery_dependencies := Ice
IceDiscovery[shared]_cppflags := -DICE_DISCOVERY_API_EXPORTS
IceDiscovery_cppflags := -DICE_DISCOVERY_API_EXPORTS

projects += $(project)
2 changes: 1 addition & 1 deletion cpp/src/IceIAP/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ IceIAP_platforms := iphoneos iphonesimulator

IceIAP_targetdir := $(libdir)
IceIAP_dependencies := Ice
IceIAP[shared]_cppflags := -DICEIAP_API_EXPORTS
IceIAP_cppflags := -DICEIAP_API_EXPORTS

projects += $(project)
2 changes: 1 addition & 1 deletion cpp/src/IceLocatorDiscovery/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ $(project)_libraries := IceLocatorDiscovery

IceLocatorDiscovery_targetdir := $(libdir)
IceLocatorDiscovery_dependencies := Ice
IceLocatorDiscovery[shared]_cppflags := -DICE_LOCATOR_DISCOVERY_API_EXPORTS
IceLocatorDiscovery_cppflags := -DICE_LOCATOR_DISCOVERY_API_EXPORTS

projects += $(project)
2 changes: 1 addition & 1 deletion cpp/src/IceXML/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $(project)_libraries := IceXML

IceXML_targetdir := $(libdir)
IceXML_dependencies := Ice
IceXML[shared]_cppflags := -DICE_XML_API_EXPORTS
IceXML_cppflags := -DICE_XML_API_EXPORTS
IceXML_libs := expat
IceXML_devinstall := no

Expand Down
3 changes: 1 addition & 2 deletions cpp/test/Common/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ $(project)_caninstall := no
#
TestCommon[shared]_targetdir := $(call mappingdir,$(currentdir),lib)
TestCommon_dependencies := Ice
TestCommon_cppflags := -I$(includedir) -Itest/include
TestCommon[shared]_cppflags := -DTEST_API_EXPORTS
TestCommon_cppflags := -DTEST_API_EXPORTS -I$(includedir) -Itest/include

projects += $(project)
1 change: 1 addition & 0 deletions cpp/test/IceUtil/stacktrace/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Client::run(int, char*[])
}
catch (const Ice::Exception& ex)
{
// cerr << ex << endl;
test(splitLines(ex.ice_stackTrace()).size() >= 3);
}
cout << "ok" << endl;
Expand Down
2 changes: 0 additions & 2 deletions python/modules/IcePy/Init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ PyInit_IcePy(void)
{
PyObject* module;

Ice::registerIceUDP(true);
Ice::registerIceWS(true);
Ice::registerIceDiscovery(false);
Ice::registerIceLocatorDiscovery(false);

Expand Down
3 changes: 3 additions & 0 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ def filter_source(filename):
if "ios/" in filename:
return False

if "RegisterPluginsInit_min" in filename:
return False

# Bzip2lib sources
bzip2sources = ["blocksort.c", "bzlib.c", "compress.c", "crctable.c", "decompress.c", "huffman.c", "randtable.c"]
if "bzip2-" in filename and os.path.basename(filename) not in bzip2sources:
Expand Down
2 changes: 1 addition & 1 deletion ruby/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
$srcs << f
end

$excluded = ['DLLMain.cpp', 'Main.cpp']
$excluded = ['DLLMain.cpp', 'Main.cpp', 'RegisterPluginsInit_min.cpp']

def filter(f)
# Filter sources for each platform.
Expand Down
2 changes: 0 additions & 2 deletions ruby/src/IceRuby/Init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ extern "C"
{
void ICE_DECLSPEC_EXPORT Init_IceRuby()
{
Ice::registerIceUDP(true);
Ice::registerIceWS(true);
Ice::registerIceDiscovery(false);
Ice::registerIceLocatorDiscovery(false);

Expand Down
1 change: 1 addition & 0 deletions scripts/Component.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def getFilters(self, mapping, config):
"IceSSL/configuration",
"IceDiscovery/simple",
"IceGrid/simple",
"IceUtil/stacktrace",
Copy link
Member Author

Choose a reason for hiding this comment

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

Enable this test for static builds. Otherwise, it's hard to see if we have an issue with backtraces and static builds!

"Glacier2/application",
],
["Ice/library", "Ice/plugin"],
Expand Down
6 changes: 1 addition & 5 deletions swift/src/IceImpl/IceUtil.mm
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@
public:
Init()
{
//
// Register plug-ins included in the Ice framework (a single binary file)
// See also RegisterPluginsInit.cpp in cpp/src/Ice
//
Ice::registerIceUDP(true);
Ice::registerIceWS(true);
// See also RegisterPluginsInit_all.cpp in cpp/src/Ice
Ice::registerIceDiscovery(false);
Ice::registerIceLocatorDiscovery(false);
#if defined(__APPLE__) && TARGET_OS_IPHONE != 0
Expand Down
Loading