Re: [pjsip] PJSIP for iOS (ARMv6 and ARMv7)

M
Ming
Thu, Aug 11, 2011 2:25 AM

Hi all,

Thanks for the valuable discussion. I already updated the iPhone's
Getting Started guide on how to support multiple architectures
(https://trac.pjsip.org/repos/wiki/Getting-Started/iPhone#Supportingmultiplearchitecturesarmv6andarmv7)

Best regards,
Ming

On Sun, Jul 31, 2011 at 6:45 AM, Samuel Vinson samuelv@laposte.net wrote:

It's possible to create universal binary without many modifications in
pjsip.
In configure-iphone file, you have to change:

-       gccpath="${DEVPATH}/usr/bin/${archname}-gcc-${gccver}"
+       gccpath="${DEVPATH}/usr/bin/gcc-${gccver}"

After that, you have to create a directory where you put build-pjsip.sh file
(join to this mail).
Define the directory into the shell, PJPROJECTDIR variable.

Samuel

Le 24/06/11 16:23, s.marek@avm.de a écrit :

The new llvm compiler in Xcode 4 is able to create universal binaries
(using lipo underneath, most certainly).

So I tried to patch the PJSIP build system to work with the llvm compiler
and this is what I tried:

CC="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2"
ARCH="-arch armv6 -arch armv7" ./configure-iphone

make dep

make

The compiler has some limitations, that need some patching:
1.) for some strange reason it seems to require a space after -o
2.) -M and -E don't work together with multiple arch arguments

So I came up with this hack (quick and dirty):

$ svn diff
Index: pjsip-apps/build/Samples.mak


---=
--- pjsip-apps/build/Samples.mak        (revision 3557)
+++ pjsip-apps/build/Samples.mak        (working copy)
@@ -45,13 +45,13 @@
all: $(BINDIR) $(OBJDIR) $(EXES)

$(BINDIR)/%$(HOST_EXE): $(OBJDIR)/%$(OBJEXT) $(PJ_LIB_FILES)

  •   $(LD) $(LDOUT)$(subst /,$(HOST_PSEP),$@) \
    
  •   $(LD) $(LDOUT) $(subst /,$(HOST_PSEP),$@) \
          $(subst /,$(HOST_PSEP),$<) \
          $(_LDFLAGS)
    

$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.c
$(CC) $(_CFLAGS) \

  •     $(CC_OUT)$(subst /,$(HOST_PSEP),$@) \
    
  •     $(CC_OUT) $(subst /,$(HOST_PSEP),$@) \
        $(subst /,$(HOST_PSEP),$<)
    

$(OBJDIR):
Index: configure-iphone


---=
--- configure-iphone    (revision 3557)
+++ configure-iphone    (working copy)
@@ -106,7 +106,7 @@
export RANLIB="echo ranlib"

Use gcc -E as preprocessor instead of cpp, since cpp will find the

header files in standard /usr/include instead of in isysroot

-export CPP="${CC} ${ARCH} -E -isysroot ${SDKPATH}"
+#export CPP="${CC} ${ARCH} -E -isysroot ${SDKPATH}"

Print settings

if test "1" = "1"; then
Index: build/rules.mak


---=
--- build/rules.mak    (revision 3557)
+++ build/rules.mak    (working copy)
@@ -45,7 +45,7 @@

When generating dependency (gcc -MM), ideally we use only either

CFLAGS or CXXFLAGS (not both). But I just couldn't make if/ifeq to

work.

-DEPFLAGS = $($(APP)_CXXFLAGS) $($(APP)_CFLAGS)
+DEPFLAGS = $(subst armv6,armv7,$($(APP)_CXXFLAGS) $($(APP)_CFLAGS))

Dependency file

DEP_FILE := .$(app)-$(TARGET_NAME).depend
@@ -84,7 +84,7 @@

$(EXE): $(OBJDIRS) $(OBJS) $($(APP)_EXTRA_DEP)
if test ! -d $(BINDIR); then $(subst @@,$(subst
/,$(HOST_PSEP),$(BINDIR)),$(HOST_MKDIR)); fi

  •   $(LD) $(LDOUT)$(subst /,$(HOST_PSEP),$(EXE)) \
    
  •   $(LD) $(LDOUT) $(subst /,$(HOST_PSEP),$(EXE)) \
          $(subst /,$(HOST_PSEP),$(OBJS)) $($(APP)_LDFLAGS)
    

$(OBJDIR)/$(app).o: $(OBJDIRS) $(OBJS)
@@ -117,22 +117,22 @@

$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.m
$(CC) $($(APP)_CFLAGS) \

  •           $(CC_OUT)$(subst /,$(HOST_PSEP),$@) \
    
  •           $(CC_OUT) $(subst /,$(HOST_PSEP),$@) \
              $(subst /,$(HOST_PSEP),$<)
    

$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.c
$(CC) $($(APP)_CFLAGS) \

  •           $(CC_OUT)$(subst /,$(HOST_PSEP),$@) \
    
  •           $(CC_OUT) $(subst /,$(HOST_PSEP),$@) \
              $(subst /,$(HOST_PSEP),$<)
    

$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.S
$(CC) $($(APP)_CFLAGS) \

  •           $(CC_OUT)$(subst /,$(HOST_PSEP),$@) \
    
  •           $(CC_OUT) $(subst /,$(HOST_PSEP),$@) \
              $(subst /,$(HOST_PSEP),$<)
    

$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.cpp
$(CC) $($(APP)_CXXFLAGS) \

  •           $(CC_OUT)$(subst /,$(HOST_PSEP),$@) \
    
  •           $(CC_OUT) $(subst /,$(HOST_PSEP),$@) \
              $(subst /,$(HOST_PSEP),$<)
    

$(OBJDIRS):

That works for the moment, but is nothing to check in. I don't know what
this -E line in configure-iphone is good for (is there any C++ in PJSIP?)
and the $(subst) thing in rules.mak is, well, the definition of a hack in
itself. $DEPFLAGS is used together with -M, which doesn't work with "-arch
armv6 -arch armv7", but is happy with "-arch armv7 -arch armv7". ;)

Maybe someone is able to clear that up a bit and make something useful out
of it?

Regards,
Sebastian.

pjsip-bounces@lists.pjsip.org schrieb am 24.06.2011 11:21:05:

| You should compile separately for both arch armv6 and armv7 and
| combine libraries with tool lipo


Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org


Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

Hi all, Thanks for the valuable discussion. I already updated the iPhone's Getting Started guide on how to support multiple architectures (https://trac.pjsip.org/repos/wiki/Getting-Started/iPhone#Supportingmultiplearchitecturesarmv6andarmv7) Best regards, Ming On Sun, Jul 31, 2011 at 6:45 AM, Samuel Vinson <samuelv@laposte.net> wrote: > It's possible to create universal binary without many modifications in > pjsip. > In configure-iphone file, you have to change: > > -       gccpath="${DEVPATH}/usr/bin/${archname}-gcc-${gccver}" > +       gccpath="${DEVPATH}/usr/bin/gcc-${gccver}" > > After that, you have to create a directory where you put build-pjsip.sh file > (join to this mail). > Define the directory into the shell, PJPROJECTDIR variable. > > Samuel > > Le 24/06/11 16:23, s.marek@avm.de a écrit : > > The new llvm compiler in Xcode 4 is able to create universal binaries > (using lipo underneath, most certainly). > > So I tried to patch the PJSIP build system to work with the llvm compiler > and this is what I tried: > > # > CC="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2" > ARCH="-arch armv6 -arch armv7" ./configure-iphone > # make dep > # make > > The compiler has some limitations, that need some patching: > 1.) for some strange reason it seems to require a space after -o > 2.) -M and -E don't work together with multiple arch arguments > > So I came up with this hack (quick and dirty): > > $ svn diff > Index: pjsip-apps/build/Samples.mak > =================================================================== > --- pjsip-apps/build/Samples.mak (revision 3557) > +++ pjsip-apps/build/Samples.mak (working copy) > @@ -45,13 +45,13 @@ > all: $(BINDIR) $(OBJDIR) $(EXES) > > $(BINDIR)/%$(HOST_EXE): $(OBJDIR)/%$(OBJEXT) $(PJ_LIB_FILES) > - $(LD) $(LDOUT)$(subst /,$(HOST_PSEP),$@) \ > + $(LD) $(LDOUT) $(subst /,$(HOST_PSEP),$@) \ > $(subst /,$(HOST_PSEP),$<) \ > $(_LDFLAGS) > > $(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.c > $(CC) $(_CFLAGS) \ > - $(CC_OUT)$(subst /,$(HOST_PSEP),$@) \ > + $(CC_OUT) $(subst /,$(HOST_PSEP),$@) \ > $(subst /,$(HOST_PSEP),$<) > > $(OBJDIR): > Index: configure-iphone > =================================================================== > --- configure-iphone (revision 3557) > +++ configure-iphone (working copy) > @@ -106,7 +106,7 @@ > export RANLIB="echo ranlib" > # Use gcc -E as preprocessor instead of cpp, since cpp will find the > # header files in standard /usr/include instead of in isysroot > -export CPP="${CC} ${ARCH} -E -isysroot ${SDKPATH}" > +#export CPP="${CC} ${ARCH} -E -isysroot ${SDKPATH}" > > # Print settings > if test "1" = "1"; then > Index: build/rules.mak > =================================================================== > --- build/rules.mak (revision 3557) > +++ build/rules.mak (working copy) > @@ -45,7 +45,7 @@ > # When generating dependency (gcc -MM), ideally we use only either > # CFLAGS or CXXFLAGS (not both). But I just couldn't make if/ifeq to > work. > # > -DEPFLAGS = $($(APP)_CXXFLAGS) $($(APP)_CFLAGS) > +DEPFLAGS = $(subst armv6,armv7,$($(APP)_CXXFLAGS) $($(APP)_CFLAGS)) > > # Dependency file > DEP_FILE := .$(app)-$(TARGET_NAME).depend > @@ -84,7 +84,7 @@ > > $(EXE): $(OBJDIRS) $(OBJS) $($(APP)_EXTRA_DEP) > if test ! -d $(BINDIR); then $(subst @@,$(subst > /,$(HOST_PSEP),$(BINDIR)),$(HOST_MKDIR)); fi > - $(LD) $(LDOUT)$(subst /,$(HOST_PSEP),$(EXE)) \ > + $(LD) $(LDOUT) $(subst /,$(HOST_PSEP),$(EXE)) \ > $(subst /,$(HOST_PSEP),$(OBJS)) $($(APP)_LDFLAGS) > > $(OBJDIR)/$(app).o: $(OBJDIRS) $(OBJS) > @@ -117,22 +117,22 @@ > > $(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.m > $(CC) $($(APP)_CFLAGS) \ > - $(CC_OUT)$(subst /,$(HOST_PSEP),$@) \ > + $(CC_OUT) $(subst /,$(HOST_PSEP),$@) \ > $(subst /,$(HOST_PSEP),$<) > > $(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.c > $(CC) $($(APP)_CFLAGS) \ > - $(CC_OUT)$(subst /,$(HOST_PSEP),$@) \ > + $(CC_OUT) $(subst /,$(HOST_PSEP),$@) \ > $(subst /,$(HOST_PSEP),$<) > > $(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.S > $(CC) $($(APP)_CFLAGS) \ > - $(CC_OUT)$(subst /,$(HOST_PSEP),$@) \ > + $(CC_OUT) $(subst /,$(HOST_PSEP),$@) \ > $(subst /,$(HOST_PSEP),$<) > > $(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.cpp > $(CC) $($(APP)_CXXFLAGS) \ > - $(CC_OUT)$(subst /,$(HOST_PSEP),$@) \ > + $(CC_OUT) $(subst /,$(HOST_PSEP),$@) \ > $(subst /,$(HOST_PSEP),$<) > > $(OBJDIRS): > > That works for the moment, but is nothing to check in. I don't know what > this -E line in configure-iphone is good for (is there any C++ in PJSIP?) > and the $(subst) thing in rules.mak is, well, the definition of a hack in > itself. $DEPFLAGS is used together with -M, which doesn't work with "-arch > armv6 -arch armv7", but is happy with "-arch armv7 -arch armv7". ;) > > Maybe someone is able to clear that up a bit and make something useful out > of it? > > Regards, > Sebastian. > > > pjsip-bounces@lists.pjsip.org schrieb am 24.06.2011 11:21:05: > > | You should compile separately for both arch armv6 and armv7 and > | combine libraries with tool lipo > > > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip@lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org > > > > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip@lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org > >